You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Pavel Pervov (JIRA)" <ji...@apache.org> on 2008/02/01 15:59:11 UTC

[jira] Updated: (HARMONY-5318) [drlvm][classloader] About the loading constraints

     [ https://issues.apache.org/jira/browse/HARMONY-5318?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pavel Pervov updated HARMONY-5318:
----------------------------------

    Summary: [drlvm][classloader] About the loading constraints  (was: [drlvm][class_support] About the loading constraints)

> [drlvm][classloader] About the loading constraints
> --------------------------------------------------
>
>                 Key: HARMONY-5318
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5318
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>    Affects Versions: 5.0M4
>         Environment: test 1 :winXP SP2,  sun JDK1.5_12
> test 2 :Ubuntu 7. 04, harmony 
>  
>            Reporter: Wang Xiaobing
>         Attachments: test suit.rar
>
>
> Loading constraint is a new regulation since sun jdk 1.2.I use a test suit, finding that there are some difference between harmony and sun jdk 1.5 about the loading constraint. And I am not quite sure about the native resolution of harmony. Who can help me to explain why??? (for all the source codes of this example, you can find them here in the book of 
> "inside the java virtual machine second edition"  http://www.artima.com/insidejvm/ed2/linkmod20.html )
> There are two Spoofed.class. One is under the current direction, the other is under the direction : greeters/ . They are different but with the same name.
> Spoofed.class
> public class Spoofed {
>     private int secretValue = 42;
>     public int giveMeFive() {
>         return 5;
>     }
>     static {
>         System.out.println(
>             "linking/ex8/Spoofed initialized.");
>     }
> }
> greeters/Spoofed.class
> public class Spoofed {
>     private int secretValue = 100;
>     public int giveMeFive() {
>         return secretValue;
>     }
>     static {
>         System.out.println(
>             "linking/ex8/greeters/Spoofed initialized.");
>     }
> }
>  
> The method to invoke loading is as followed:
>     public void greet() {
>         Spoofed spoofed = new Spoofed();
>         System.out.println("secret val = "+ spoofed.giveMeFive());
>         spoofed = Delegated.getSpoofed();
>         System.out.println("secret val = "+ spoofed.giveMeFive());
>     }
> In which the Delegated.class:
> public class Delegated {
>     public static Spoofed getSpoofed() {
>         return new Spoofed();
>     }
> }
>  
> Then we define the classloader to load the Spoofed.class in greeters. The main function invokes greet().Results show as follows:
>  
> Result In sun jdk 1.5:
> D:\linking\ex8>java Greet greeters Cracker
> linking/ex8/greeters/Spoofed initialized.
> secret val = 100
> Exception in thread "main" java.lang.LinkageError: Class Spoofed violates loader
>  constraints
>         at java.lang.ClassLoader.defineClass1(Native Method)
>         at java.lang.ClassLoader.defineClass(Unknown Source)
>         at java.security.SecureClassLoader.defineClass(Unknown Source)
>         at java.net.URLClassLoader.defineClass(Unknown Source)
>         at java.net.URLClassLoader.access$100(Unknown Source)
>         at java.net.URLClassLoader$1.run(Unknown Source)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at java.net.URLClassLoader.findClass(Unknown Source)
>         at java.lang.ClassLoader.loadClass(Unknown Source)
>         at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>         at java.lang.ClassLoader.loadClass(Unknown Source)
>         at java.lang.ClassLoader.loadClassInternal(Unknown Source)
>         at Delegated.getSpoofed(Delegated.java:7)
>         at Cracker.greet(Cracker.java:13)
>         at Greet.main(Greet.java:39)
>  
> Result In harmony:
> littleice@littleice-desktop:/trunk/target/hdk/jdk/jre/bin$ ./java Greet greeters Cracker
> linking/ex8/greeters/Spoofed initialized.
> secret val = 100
> linking/ex8/Spoofed initialized.
> secret val = 5
> littleice@littleice-desktop:/trunk/target/hdk/jdk/jre/bin$

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