harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r599053 - in /harmony/enhanced/drlvm/trunk/vm/vmcore: build/ include/ src/class_support/ src/kernel_classes/javasrc/java/lang/ src/kernel_classes/native/
Date Wed, 28 Nov 2007 16:20:52 GMT
Author: gshimansky
Date: Wed Nov 28 08:20:51 2007
New Revision: 599053

URL: http://svn.apache.org/viewvc?rev=599053&view=rev
Log:
Applied patch from HARMONY-4965
[drlvm][kernel] ClassLoader.findLoadedClass() does not cache not owned classes


Modified:
    harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Class.java
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/ClassLoader.java
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_ClassLoader.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMClassRegistry.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp?rev=599053&r1=599052&r2=599053&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp Wed Nov 28 08:20:51 2007
@@ -153,6 +153,7 @@
     is_warn_enabled;
     Java_java_lang_ClassLoader_defineClass0;
     Java_java_lang_ClassLoader_findLoadedClass;
+    Java_java_lang_ClassLoader_registerInitiatedClass;
     Java_java_lang_EMThreadSupport_getTimeout;
     Java_java_lang_EMThreadSupport_needProfilerThreadSupport;
     Java_java_lang_EMThreadSupport_onTimeout;

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h?rev=599053&r1=599052&r2=599053&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h Wed Nov 28 08:20:51 2007
@@ -180,6 +180,7 @@
         }
     }
     bool InsertClass(Class* clss);
+    void InsertInitiatedClass(Class* clss);
     Class* AllocateAndReportInstance(const Global_Env* env, Class* klass);
     Class* NewClass(const Global_Env* env, const String* name);
     Package* ProvidePackage(Global_Env* env, const String *class_name, const char *jar);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp?rev=599053&r1=599052&r2=599053&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp Wed Nov 28 08:20:51
2007
@@ -1737,6 +1737,13 @@
     return true;
 }
 
+
+void ClassLoader::InsertInitiatedClass(Class* clss)
+{
+    LMAutoUnlock aulock(&m_lock);
+    m_initiatedClasses->Insert(clss->get_name(), clss);
+}
+
 void BootstrapClassLoader::ReportAndExit(const char* exnclass, std::stringstream& exnmsg)

 {
     std::stringstream ss;

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Class.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Class.java?rev=599053&r1=599052&r2=599053&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Class.java
(original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Class.java
Wed Nov 28 08:20:51 2007
@@ -146,6 +146,12 @@
                 clazz = classLoader.loadClass(name);
             }
         }
+        if(classLoader != null && classLoader.findLoadedClass(name) == null) {
+            // classloader overloads loadClass method though it is not
+            // generally recommended
+            // have to register initiating loader for clazz from here
+            classLoader.registerInitiatedClass(clazz);
+        }
         if(clazz == null) {
             throw new ClassNotFoundException(name);
         }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/ClassLoader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/ClassLoader.java?rev=599053&r1=599052&r2=599053&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/ClassLoader.java
(original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/ClassLoader.java
Wed Nov 28 08:20:51 2007
@@ -549,6 +549,12 @@
     }
 
     /**
+     * Registers this class loader as initiating for a class
+     * Declared as package private to use it from java.lang.Class.forName
+     */
+    native void registerInitiatedClass(Class clazz);
+
+    /**
      * @com.intel.drl.spec_ref
      */
     protected synchronized Class<?> loadClass(String name, boolean resolve)
@@ -568,6 +574,15 @@
             } else {
                 try {
                     clazz = parentClassLoader.loadClass(name);
+                    try {
+                        VMStack.getCallerClass(0)
+                            .asSubclass(ClassLoader.class);
+                    } catch(ClassCastException ex) {
+                        // caller class is not a subclass of java/lang/ClassLoader
+                        // so, register as initiating loader as we are called from
+                        // outside of ClassLoader delegation chain
+                        registerInitiatedClass(clazz);
+                    }
                 } catch (ClassNotFoundException e) {
                 }
             }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_ClassLoader.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_ClassLoader.h?rev=599053&r1=599052&r2=599053&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_ClassLoader.h
(original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_ClassLoader.h
Wed Nov 28 08:20:51 2007
@@ -37,62 +37,14 @@
 Java_java_lang_ClassLoader_findLoadedClass(JNIEnv *, jobject, 
     jstring);
 
-/*                                          
- * Method: java.lang.ClassLoader.defineClass0(Ljava/lang/String;[BII)Ljava/lang/Class;
- * Throws: java.lang.ClassFormatError
- */
-JNIEXPORT jclass JNICALL
-Java_java_lang_ClassLoader_defineClass0(JNIEnv *, jobject, 
-    jstring, jbyteArray, jint, jint);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _JAVA_LANG_CLASSLOADER_H */
-
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-#include <jni.h>
-
-
-/* Header for class java.lang.ClassLoader */
-
-#ifndef _JAVA_LANG_CLASSLOADER_H
-#define _JAVA_LANG_CLASSLOADER_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* Native methods */
-
 /*
  * Method: java.lang.ClassLoader.findLoadedClass(Ljava/lang/String;)Ljava/lang/Class;
  */
-JNIEXPORT jclass JNICALL
-Java_java_lang_ClassLoader_findLoadedClass(JNIEnv *, jobject, 
-    jstring);
+JNIEXPORT void JNICALL
+Java_java_lang_ClassLoader_registerInitiatedClass(JNIEnv *, jobject, jclass);
 
-/*
- * Method: java.lang.ClassLoader.defineClass(Ljava/lang/String;[BII)Ljava/lang/Class;
+/*                                          
+ * Method: java.lang.ClassLoader.defineClass0(Ljava/lang/String;[BII)Ljava/lang/Class;
  * Throws: java.lang.ClassFormatError
  */
 JNIEXPORT jclass JNICALL
@@ -105,4 +57,3 @@
 #endif
 
 #endif /* _JAVA_LANG_CLASSLOADER_H */
-

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMClassRegistry.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMClassRegistry.cpp?rev=599053&r1=599052&r2=599053&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMClassRegistry.cpp
(original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMClassRegistry.cpp
Wed Nov 28 08:20:51 2007
@@ -117,6 +117,14 @@
     return clss ? jni_class_from_handle(jenv, clss) : NULL; 
 }
 
+JNIEXPORT void JNICALL
+Java_java_lang_ClassLoader_registerInitiatedClass(JNIEnv* env, jobject loader, jclass clazz)
{
+    ClassLoader* cl = class_loader_lookup(loader);
+    Class* clss = jclass_to_struct_Class(clazz);
+    cl->InsertInitiatedClass(clss);
+}
+
+
 /*
  * Class:     java_lang_VMClassRegistry
  * Method:    getClass



Mime
View raw message