You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Wang Xiaobing (JIRA)" <ji...@apache.org> on 2007/12/17 11:30:42 UTC
[jira] Created: (HARMONY-5318) About the loading constraints
About the loading constraints
-----------------------------
Key: HARMONY-5318
URL: https://issues.apache.org/jira/browse/HARMONY-5318
Project: Harmony
Issue Type: Test
Components: JDK
Environment: test 1 :winXP SP2, sun JDK1.5_12
test 2 :Ubuntu 7. 04, harmony
Reporter: Wang Xiaobing
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.
[jira] Updated: (HARMONY-5318) [drlvm][classloader] About the
loading constraints
Posted by "Pavel Pervov (JIRA)" <ji...@apache.org>.
[ 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.
[jira] Updated: (HARMONY-5318) [drlvm][class_support] About the
loading constraints
Posted by "Alexey Varlamov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-5318?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alexey Varlamov updated HARMONY-5318:
-------------------------------------
Component/s: (was: JDK)
DRLVM
Patch Info: (was: [Patch Available])
Affects Version/s: 5.0M4
Issue Type: Bug (was: Test)
Summary: [drlvm][class_support] About the loading constraints (was: About the loading constraints)
> [drlvm][class_support] 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.
[jira] Commented: (HARMONY-5318) [drlvm][class_support] About the
loading constraints
Posted by "Vladimir Beliaev (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-5318?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12564766#action_12564766 ]
Vladimir Beliaev commented on HARMONY-5318:
-------------------------------------------
The issue related to classloading - let's get it renamed to [drlvm][classloader] to simplify its filtering (make it included to list of other classloader issues).
> [drlvm][class_support] 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.
[jira] Updated: (HARMONY-5318) About the loading constraints
Posted by "Wang Xiaobing (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-5318?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Wang Xiaobing updated HARMONY-5318:
-----------------------------------
Attachment: test suit.rar
this is the source codes of this test suit
> About the loading constraints
> -----------------------------
>
> Key: HARMONY-5318
> URL: https://issues.apache.org/jira/browse/HARMONY-5318
> Project: Harmony
> Issue Type: Test
> Components: JDK
> 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.