About the loading constraint
4 Message(s) by 2 Author(s) originally posted in harmony developer java
| From: Xiaobing Wong |
Date: Friday, December 14, 2007
|
------=_Part_441_24854211.1197627042528
Content-Disposition: inline
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
load ing constraint. And I am not quite sure about the native resolution
of harmony. Who can help me to explain why???
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@xxxxxxxxxxx:/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@xxxxxxxxxxx:/trunk/target/hdk/jdk/jre/bin$
------=_Part_441_24854211.1197627042528--
| From: Pavel Pervov |
Date: Friday, December 14, 2007
|
------=_Part_150_5281096.1197629770355
Content-Disposition: inline
Xiaobing,
this is interesting observation indeed and it certainly deserves JIRA.
Could you, please,
file a JIRA and provide the whole test case and citation
(or link) to the spec where this behaviour is defined?
wrote in message:
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.5about
the loading constraint. And I am not quite sure about the native
resolution
of harmony. Who can help me to explain why???
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@xxxxxxxxxxx:/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@xxxxxxxxxxx:/trunk/target/hdk/jdk/jre/bin$
--
Pavel Pervov,
Intel Enterprise Solutions Software Division
------=_Part_150_5281096.1197629770355--
| From: Xiaobing Wong |
Date: Monday, December 17, 2007
|
------=_Part_7864_28409170.1197887562751
Content-Disposition: inline
ok~
wrote in message:
Xiaobing,
this is interesting observation indeed and it certainly deserves JIRA.
Could you, please, file a JIRA and provide the whole test case and
citation
(or link) to the spec where this behaviour is defined?
Thank you very much.
wrote in message:
>
> 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.5about
> the loading constraint. And I am not quite sure about the native
> resolution
> of harmony. Who can help me to explain why???
>
>
>
> 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@xxxxxxxxxxx:/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@xxxxxxxxxxx:/trunk/target/hdk/jdk/jre/bin$
>
--
Pavel Pervov,
Intel Enterprise Solutions Software Division
------=_Part_7864_28409170.1197887562751--
| From: Pavel Pervov |
Date: Monday, December 17, 2007
|
------=_Part_556_30892177.1197906695325
Content-Disposition: inline
Thanks. I will look into this.
wrote in message:
ok~
wrote in message:
> Xiaobing,
>
> this is interesting observation indeed and it certainly deserves JIRA.
>
> Could you, please, file a JIRA and provide the whole test case and
> citation
> (or link) to the spec where this behaviour is defined?
>
> Thank you very much.
>
>
wrote in message:
> >
> > 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.5about
> > the loading constraint. And I am not quite sure about the native
> > resolution
> > of harmony. Who can help me to explain why???
> >
> >
> >
> > 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@xxxxxxxxxxx:/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@xxxxxxxxxxx:/trunk/target/hdk/jdk/jre/bin$
> >
>
>
>
> --
> Pavel Pervov,
> Intel Enterprise Solutions Software Division
>
--
Pavel Pervov,
Intel Enterprise Solutions Software Division
------=_Part_556_30892177.1197906695325--
Next Message: [testing] M4 candidate (r603534) testing status.
Blogs related to About the loading constraint
Transitive persistence is true for (Web hosting companies) Java ...
Persistence by reachability guarantees referential integrity; any object graph can be completely re-created by
loading the persistent root object. An application may walk the object network from association to association without ever
...
iJAM, Formalized Class Loading
Though the paper provides a formalization of the class
loading strategy, the modification it proposes is actually quite simple. Standard
Java class
loading rules is parent first, then self. In a modern
Java system, there can be many
...
Does your bad Java code need help? (from Rules and Flow)
Our NumberGuess.
java has a standard main() method, which is where our program starts when we run it (either via Eclipse , or the command line).
Loading the Business Rules - NumberGuessExample.
java main() method
...
Subject: Multiple Errors Running Designer - by: btgrant
Main.run(Main.
java:1169) Building workspace: Errors during build. Errors running builder 'Workflow Visual Connector Builder' on project 'ApplicationDevelopment'. Class org/xml/sax/InputSource violates loader
constraints Class
...
ADF security in your project
ADF Security implementation can be viewed as an extension to the standard J2EE container security and is executed after the standard security
constraints have been processed. It is integrated in ADF of jdeveloper 11g and is implemented
...
Java Server Faces - Form Based Container Managed Authentication
The user logs in through the login page and if the username and password match that of the database, then the user object is populated, added to the session and checked for existance prior to
loading each and every page.
...