You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Nikolay Chugunov (JIRA)" <ji...@apache.org> on 2006/10/06 15:54:21 UTC

[jira] Created: (HARMONY-1756) Dynamic class loading work incorrectly

Dynamic class loading work incorrectly
--------------------------------------

                 Key: HARMONY-1756
                 URL: http://issues.apache.org/jira/browse/HARMONY-1756
             Project: Harmony
          Issue Type: Bug
          Components: DRLVM
            Reporter: Nikolay Chugunov


Dynamic class loading work incorrectly:
Code for reproduction:
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import junit.framework.TestCase;

public class Bug extends TestCase {
    private static String className = "EmptyClass";

    public void test() throws Exception {
        MyClassLoader classLoader = new MyClassLoader();
        System.out.println("Check point");
        classLoader.loadClass(className).newInstance();
        System.out.println("PASSED");
    }

    private class MyClassLoader extends ClassLoader {
        private MyClassLoader() throws IOException {
            InputStream in = new FileInputStream(
                "C:\\" + className + ".class");
            byte[] b = new byte[in.available()];
            in.read(b);
            in.close();
            defineClass(className, b, 0, b.length);
        }
    }
}
public class EmptyClass{
}

To reproduce compile classes and then move EmptyClass class to
C:\ directory which is not in class path and then run this test.

Output on RI 1.5:
Check point
PASSED

Output on Harmony r450941:
Check point
java.lang.ClassNotFoundException: Can not find class EmptyClass
	at java.lang.ClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at Bug.test(Bug.java:15)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (HARMONY-1756) Dynamic class loading work incorrectly

Posted by "Geir Magnusson Jr (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-1756?page=comments#action_12442746 ] 
            
Geir Magnusson Jr commented on HARMONY-1756:
--------------------------------------------

You sure?  A slightly modified test - getting rid of JUnit, putting class in /geir/home/ and adding a main() method works...

can you retest w/ head?

> Dynamic class loading work incorrectly
> --------------------------------------
>
>                 Key: HARMONY-1756
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1756
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Nikolay Chugunov
>
> Dynamic class loading work incorrectly:
> Code for reproduction:
> import java.io.FileInputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import junit.framework.TestCase;
> public class Bug extends TestCase {
>     private static String className = "EmptyClass";
>     public void test() throws Exception {
>         MyClassLoader classLoader = new MyClassLoader();
>         System.out.println("Check point");
>         classLoader.loadClass(className).newInstance();
>         System.out.println("PASSED");
>     }
>     private class MyClassLoader extends ClassLoader {
>         private MyClassLoader() throws IOException {
>             InputStream in = new FileInputStream(
>                 "C:\\" + className + ".class");
>             byte[] b = new byte[in.available()];
>             in.read(b);
>             in.close();
>             defineClass(className, b, 0, b.length);
>         }
>     }
> }
> public class EmptyClass{
> }
> To reproduce compile classes and then move EmptyClass class to
> C:\ directory which is not in class path and then run this test.
> Output on RI 1.5:
> Check point
> PASSED
> Output on Harmony r450941:
> Check point
> java.lang.ClassNotFoundException: Can not find class EmptyClass
> 	at java.lang.ClassLoader.findClass(Unknown Source)
> 	at java.lang.ClassLoader.loadClass(Unknown Source)
> 	at java.lang.ClassLoader.loadClass(Unknown Source)
> 	at Bug.test(Bug.java:15)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (HARMONY-1756) Dynamic class loading work incorrectly

Posted by "Nikolay Chugunov (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-1756?page=comments#action_12442932 ] 
            
Nikolay Chugunov commented on HARMONY-1756:
-------------------------------------------

The bug still exists on svn = r463908, (Oct 16 2006) Windows microsoft comiler and Linux ia32 gcc with the similiar stack. I improved code for reproduction:
import java.io.FileInputStream;
import java.io.InputStream;
/**
 * To correct run test remove compiled EmptyClass class from class path.
 */
public class Jira1756 {
    private static String className = "EmptyClass";

    public static void main(String[] args) throws Exception {
        try {
            ClassLoader.getSystemClassLoader().loadClass(className);
            System.out.println("Remove EmptyClass from class path");
            return;
        } catch (ClassNotFoundException ex) {
        }
        MyClassLoader classLoader = new MyClassLoader();
        System.out.println("Check point");
        classLoader.loadClass(className).newInstance();
        System.out.println("PASSED");
    }

    private static class MyClassLoader extends ClassLoader {
        private MyClassLoader() throws Exception {
            InputStream in = new FileInputStream(
                "C:\\" + className + ".class");
            byte[] b = new byte[in.available()];
            in.read(b);
            in.close();
            defineClass(className, b, 0, b.length);
        }
    }
}

> Dynamic class loading work incorrectly
> --------------------------------------
>
>                 Key: HARMONY-1756
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1756
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Nikolay Chugunov
>
> Dynamic class loading work incorrectly:
> Code for reproduction:
> import java.io.FileInputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import junit.framework.TestCase;
> public class Bug extends TestCase {
>     private static String className = "EmptyClass";
>     public void test() throws Exception {
>         MyClassLoader classLoader = new MyClassLoader();
>         System.out.println("Check point");
>         classLoader.loadClass(className).newInstance();
>         System.out.println("PASSED");
>     }
>     private class MyClassLoader extends ClassLoader {
>         private MyClassLoader() throws IOException {
>             InputStream in = new FileInputStream(
>                 "C:\\" + className + ".class");
>             byte[] b = new byte[in.available()];
>             in.read(b);
>             in.close();
>             defineClass(className, b, 0, b.length);
>         }
>     }
> }
> public class EmptyClass{
> }
> To reproduce compile classes and then move EmptyClass class to
> C:\ directory which is not in class path and then run this test.
> Output on RI 1.5:
> Check point
> PASSED
> Output on Harmony r450941:
> Check point
> java.lang.ClassNotFoundException: Can not find class EmptyClass
> 	at java.lang.ClassLoader.findClass(Unknown Source)
> 	at java.lang.ClassLoader.loadClass(Unknown Source)
> 	at java.lang.ClassLoader.loadClass(Unknown Source)
> 	at Bug.test(Bug.java:15)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira