harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stepan Mishura (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-4965) [drlvm][kernel] ClassLoader.findLoadedClass() does not cache not owned classes
Date Thu, 29 Nov 2007 05:36:43 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-4965?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12546567
] 

Stepan Mishura commented on HARMONY-4965:
-----------------------------------------

The commit is the reason of 2 classlib test crashes on all platforms:
org.apache.harmony.luni.tests.java.lang.ClassTest
org.apache.harmony.sql.tests.java.sql.DriverManagerTest

For example ClassTest crashes on Linux_x86 with:
    [junit] Running org.apache.harmony.luni.tests.java.lang.ClassTest
    [junit] SIGSEGV in VM code.
    [junit] Stack trace:
    [junit]   0: jclass_to_struct_Class(_jobject*) (??:-1)
    [junit]   1: Java_java_lang_ClassLoader_registerInitiatedClass (??:-1)
    [junit]   2: 0x52E4E30B  <Generated stub>
    [junit]   3: java/lang/Class.forName(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;
(Class.java:153)
    [junit]   4: java/lang/Class.forName(Ljava/lang/String;)Ljava/lang/Class; (Class.java:103)
    [junit]   5: org/apache/harmony/luni/tests/java/lang/ClassTest.test_forName_arrays()V
(ClassTest.java:771)
    [junit]   6: ?? (??:-1)
    [junit]   7: .L866 (??:-1)
    [junit]   8: DrlEMImpl::executeMethod(_jmethodID*, jvalue*, jvalue*) (??:-1)
    [junit]   9: ExecuteMethod (??:-1)
    [junit]  10: vm_execute_java_method_array (??:-1)
    [junit]  11: call_method_no_ref_result(JNIEnv_External*, _jobject*, _jmethodID*, jvalue*,
jvalue*, int) (??:-1)
    [junit]  12: CallVoidMethodA(JNIEnv_External*, _jobject*, _jmethodID*, jvalue*) (??:-1)
    [junit]  13: .L508 (??:-1)
    [junit]  14: 0x52E4A59A  <Generated stub>
    [junit]  15: java/lang/reflect/Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
(Method.java:317)
    [junit]  16: junit/framework/TestCase.runTest()V (TestCase.java:154)
    [junit]  17: junit/framework/TestCase.runBare()V (TestCase.java:127)
    [junit]  18: junit/framework/TestResult$1.protect()V (TestResult.java:106)
    [junit]  19: junit/framework/TestResult.runProtected(Ljunit/framework/Test;Ljunit/framework/Protectable;)V
(TestResult.java:124)
    [junit]  20: junit/framework/TestResult.run(Ljunit/framework/TestCase;)V (TestResult.java:109)
    [junit]  21: junit/framework/TestCase.run(Ljunit/framework/TestResult;)V (TestCase.java:118)
    [junit]  22: junit/framework/TestSuite.runTest(Ljunit/framework/Test;Ljunit/framework/TestResult;)V
(TestSuite.java:208)
    [junit]  23: junit/framework/TestSuite.run(Ljunit/framework/TestResult;)V (TestSuite.java:203)
    [junit]  24: org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.run()V (JUnitTestRunner.java:297)
    [junit]  25: org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.launch(Lorg/apache/tools/ant/taskdefs/optional/junit/JUnitTest;ZZZZLjava/util/Properties;)I
(JUnitTestRunner.java:672)
    [junit]  26: org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.main([Ljava/lang/String;)V
(JUnitTestRunner.java:567)
    [junit]  27: ?? (??:-1)
    [junit]  28: .L866 (??:-1)
    [junit]  29: DrlEMImpl::executeMethod(_jmethodID*, jvalue*, jvalue*) (??:-1)
    [junit]  30: ExecuteMethod (??:-1)
    [junit]  31: vm_execute_java_method_array (??:-1)
    [junit]  32: call_static_method_no_ref_result(JNIEnv_External*, _jobject*, _jmethodID*,
jvalue*, jvalue*) (??:-1)
    [junit]  33: CallStaticVoidMethodV(JNIEnv_External*, _jobject*, _jmethodID*, char*) (??:-1)
    [junit]  34: CallStaticVoidMethod(JNIEnv_External*, _jobject*, _jmethodID*, ...) (??:-1)
    [junit]  35: main_runJavaMain (??:-1)
    [junit]  36: invocation (??:-1)
    [junit]  37: gpProtectedMain (??:-1)
    [junit]  38: main (??:-1)
    [junit]  39: __libc_start_main (??:-1)
    [junit]  40: _start (../sysdeps/i386/elf/start.S:105)
    [junit] <end of stack trace>
    [junit] Test org.apache.harmony.luni.tests.java.lang.ClassTest FAILED


> [drlvm][kernel] ClassLoader.findLoadedClass() does not cache not owned classes
> ------------------------------------------------------------------------------
>
>                 Key: HARMONY-4965
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4965
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Sergey Dmitriev
>            Assignee: Gregory Shimansky
>         Attachments: classloadertest2.java, H4965.patch, test.java
>
>
> I've found an issue with respect to class loading in Harmony. My measurements show that
fixing this can give a pretty big burst on SPECjAppServer2004 on Oracle App Server, approx
20% of score.
> The issue is quite simple: our classloader implementation does not support the caching
of classes that were loaded not by this classloader. It can be demonstrated:
> {boy@moon:~/tmp} cat classloadertest.java
> import java.io.*;
> public class classloadertest {
>     public static void main(String args[]) throws Exception {
>         MyClassLoader mycl1 = new MyClassLoader("my", ClassLoader.getSystemClassLoader());
>         MyClassLoader mycl2 = new MyClassLoader("my", mycl1);
>         // load the hi.class with mycl1; so hi.class's class loader is 'mycl1'
>         System.out.println("Class.forName(\"hi\", true, mycl1) = [" + Class.forName("hi",
true, mycl1) + "]");
>         // load the hi.class with mycl2
>         System.out.println("Class.forName(\"hi\", true, mycl2) = [" + Class.forName("hi",
true, mycl2) + "]");
>         System.out.println("mycl1.findLoadedClass(hi) = [" + mycl1.findLoadedClassPublic("hi")
+ "]");
>         System.out.println("mycl2.findLoadedClass(hi) = [" + mycl2.findLoadedClassPublic("hi")
+ "]");
>     }
>     // class loader which just loads from specified directory
>     static class MyClassLoader extends ClassLoader {
>         private String dir;
>         public MyClassLoader(String dir, ClassLoader parent) {
>             super(parent);
>             this.dir = dir;
>         }
>         public Class findClass(String name) throws ClassNotFoundException {
>             byte[] b = loadClassData(name);
>             return defineClass(name, b, 0, b.length);
>         }
>         private byte[] loadClassData(String name) throws ClassNotFoundException {
>             try {
>                 File file = new File(dir+"/"+name+".class");
>                 int length = (int) file.length();
>                 byte[] bytes = new byte[length];
>                 FileInputStream fis = new FileInputStream(file);
>                 for (int i=0; i<length; i++) {
>                     int b = fis.read();
>                     if (b == -1) {
>                         throw new ClassFormatError(name);
>                     } else {
>                         bytes[i] = (byte) b;
>                     }
>                 }
>                 if (fis.read() != -1) {
>                     throw new ClassFormatError(name);
>                 }
>                 return bytes;
>             } catch (FileNotFoundException e) {
>                 throw new ClassNotFoundException(name);
>             } catch (IOException e) {
>                 System.out.println(e);
>                 return null;
>             }
>         }
>         public Class findLoadedClassPublic(String name) {
>             return super.findLoadedClass(name);
>         }
>     }
> }
> {boy@moon:~/tmp} cat my/hi.java 
> import java.util.*;
> public class hi {
>     public static void main(String args[]) throws Exception {
>         System.out.println("hi! from "+System.getProperty("java.vm.vendor"));
>     }
> }
> {boy@moon:~/tmp} /export/jdk1.6.0/bin/java classloadertest
> Class.forName("hi", true, mycl1) = [class hi]
> Class.forName("hi", true, mycl2) = [class hi]
> mycl1.findLoadedClass(hi) = [class hi]
> mycl2.findLoadedClass(hi) = [class hi]
> {boy@moon:~/tmp} ~/harmony579850/bin/java classloadertest
> Class.forName("hi", true, mycl1) = [class hi]
> Class.forName("hi", true, mycl2) = [class hi]
> mycl1.findLoadedClass(hi) = [class hi]
> mycl2.findLoadedClass(hi) = [null]
> {boy@moon:~/tmp} 
> Please note the "mycl2.findLoadedClass(hi) = ..." lines in outputs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message