Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / MyDerby-10.3 / java / engine / org / apache / derby / impl / services / reflect / ReflectLoaderJava2.java
diff --git a/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/impl/services/reflect/ReflectLoaderJava2.java b/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/impl/services/reflect/ReflectLoaderJava2.java
new file mode 100644 (file)
index 0000000..3b14ef3
--- /dev/null
@@ -0,0 +1,84 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.impl.services.reflect.ReflectLoaderJava2\r
+\r
+   Licensed to the Apache Software Foundation (ASF) under one or more\r
+   contributor license agreements.  See the NOTICE file distributed with\r
+   this work for additional information regarding copyright ownership.\r
+   The ASF licenses this file to you under the Apache License, Version 2.0\r
+   (the "License"); you may not use this file except in compliance with\r
+   the License.  You may obtain a copy of the License at\r
+\r
+      http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.impl.services.reflect;\r
+\r
+import org.apache.derby.iapi.util.ByteArray;\r
+import org.apache.derby.iapi.sql.compile.CodeGeneration;\r
+\r
+final class ReflectLoaderJava2 extends ClassLoader {\r
+\r
+       /*\r
+       **      Fields\r
+       */\r
+\r
+       private final DatabaseClasses cf;\r
+       \r
+       /*\r
+       ** Constructor\r
+       */\r
+\r
+       ReflectLoaderJava2(ClassLoader parent, DatabaseClasses cf) {\r
+               super(parent);\r
+               this.cf = cf;\r
+       }\r
+\r
+       protected Class findClass(String name)\r
+               throws ClassNotFoundException {\r
+               return cf.loadApplicationClass(name);\r
+       }\r
+\r
+       /*\r
+       ** Implementation specific methods\r
+       ** NOTE these are COPIED from ReflectLoader as the two classes cannot be made into\r
+          a super/sub class pair. Because the Java2 one needs to call super(ClassLoader)\r
+          that was added in Java2 and it needs to not implement loadClass()\r
+       */\r
+\r
+       /**\r
+               Load a generated class from the passed in class data.\r
+       */\r
+       public LoadedGeneratedClass loadGeneratedClass(String name, ByteArray classData) {\r
+\r
+               Class jvmClass = defineClass(name, classData.getArray(), classData.getOffset(), classData.getLength());\r
+\r
+               resolveClass(jvmClass);\r
+\r
+               /*\r
+                       DJD - not enabling this yet, need more memory testing, may only\r
+                       create a factory instance when a number of instances are created.\r
+                       This would avoid a factory instance for DDL\r
+\r
+               // now generate a factory class that loads instances\r
+               int lastDot = name.lastIndexOf('.');\r
+               String factoryName = name.substring(lastDot + 1, name.length()).concat("_F");\r
+\r
+               classData = cf.buildSpecificFactory(name, factoryName);\r
+               Class factoryClass = defineClass(CodeGeneration.GENERATED_PACKAGE_PREFIX.concat(factoryName),\r
+                       classData.getArray(), classData.getOffset(), classData.getLength());\r
+               resolveClass(factoryClass);\r
+               \r
+                 */\r
+               Class factoryClass = null;\r
+\r
+               return new ReflectGeneratedClass(cf, jvmClass, factoryClass);\r
+       }\r
+}\r