Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 44289 invoked from network); 1 Feb 2008 14:59:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 Feb 2008 14:59:40 -0000 Received: (qmail 5764 invoked by uid 500); 1 Feb 2008 14:59:31 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 5743 invoked by uid 500); 1 Feb 2008 14:59:31 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 5734 invoked by uid 99); 1 Feb 2008 14:59:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Feb 2008 06:59:31 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Feb 2008 14:59:04 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 383C9714049 for ; Fri, 1 Feb 2008 06:59:11 -0800 (PST) Message-ID: <28501209.1201877951226.JavaMail.jira@brutus> Date: Fri, 1 Feb 2008 06:59:11 -0800 (PST) From: "Pavel Pervov (JIRA)" To: commits@harmony.apache.org Subject: [jira] Updated: (HARMONY-5318) [drlvm][classloader] About the loading constraints In-Reply-To: <7373370.1197887442988.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on 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.