Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 646 invoked from network); 26 Oct 2007 16:54:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Oct 2007 16:54:16 -0000 Received: (qmail 50690 invoked by uid 500); 26 Oct 2007 16:54:03 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 50672 invoked by uid 500); 26 Oct 2007 16:54:03 -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 50640 invoked by uid 99); 26 Oct 2007 16:54:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Oct 2007 09:54:03 -0700 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, 26 Oct 2007 16:54:15 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id C477B714233 for ; Fri, 26 Oct 2007 09:53:51 -0700 (PDT) Message-ID: <9305149.1193417631801.JavaMail.jira@brutus> Date: Fri, 26 Oct 2007 09:53:51 -0700 (PDT) From: "Vladimir Beliaev (JIRA)" To: commits@harmony.apache.org Subject: [jira] Commented: (HARMONY-4965) [drlvm][kernel] ClassLoader.findLoadedClass() does not cache not owned classes In-Reply-To: <20953375.1192696250676.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-4965?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12538016 ] Vladimir Beliaev commented on HARMONY-4965: ------------------------------------------- It is not clear what test is broken by this "bug" or what specification statement is (even potentially) violated. Let's have this JIRA to be "Improvement", not a "bug'... Thanks Vladimir Beliaev > [drlvm][kernel] ClassLoader.findLoadedClass() does not cache not owned classes > ------------------------------------------------------------------------------ > > Key: HARMONY-4965 > URL: https://issues.apache.org/jira/browse/HARMONY-4965 > Project: Harmony > Issue Type: Bug > Components: DRLVM > Reporter: Sergey Dmitriev > Attachments: classloadertest2.java > > > I've found an issue with respect to class loading in Harmony. My measurements show that fixing this can give a pretty big burst on SPECjAppServer2004 on Oracle App Server, approx 20% of score. > The issue is quite simple: our classloader implementation does not support the caching of classes that were loaded not by this classloader. It can be demonstrated: > {boy@moon:~/tmp} cat classloadertest.java > import java.io.*; > public class classloadertest { > public static void main(String args[]) throws Exception { > MyClassLoader mycl1 = new MyClassLoader("my", ClassLoader.getSystemClassLoader()); > MyClassLoader mycl2 = new MyClassLoader("my", mycl1); > // load the hi.class with mycl1; so hi.class's class loader is 'mycl1' > System.out.println("Class.forName(\"hi\", true, mycl1) = [" + Class.forName("hi", true, mycl1) + "]"); > // load the hi.class with mycl2 > System.out.println("Class.forName(\"hi\", true, mycl2) = [" + Class.forName("hi", true, mycl2) + "]"); > System.out.println("mycl1.findLoadedClass(hi) = [" + mycl1.findLoadedClassPublic("hi") + "]"); > System.out.println("mycl2.findLoadedClass(hi) = [" + mycl2.findLoadedClassPublic("hi") + "]"); > } > // class loader which just loads from specified directory > static class MyClassLoader extends ClassLoader { > private String dir; > public MyClassLoader(String dir, ClassLoader parent) { > super(parent); > this.dir = dir; > } > public Class findClass(String name) throws ClassNotFoundException { > byte[] b = loadClassData(name); > return defineClass(name, b, 0, b.length); > } > private byte[] loadClassData(String name) throws ClassNotFoundException { > try { > File file = new File(dir+"/"+name+".class"); > int length = (int) file.length(); > byte[] bytes = new byte[length]; > FileInputStream fis = new FileInputStream(file); > for (int i=0; i int b = fis.read(); > if (b == -1) { > throw new ClassFormatError(name); > } else { > bytes[i] = (byte) b; > } > } > if (fis.read() != -1) { > throw new ClassFormatError(name); > } > return bytes; > } catch (FileNotFoundException e) { > throw new ClassNotFoundException(name); > } catch (IOException e) { > System.out.println(e); > return null; > } > } > public Class findLoadedClassPublic(String name) { > return super.findLoadedClass(name); > } > } > } > {boy@moon:~/tmp} cat my/hi.java > import java.util.*; > public class hi { > public static void main(String args[]) throws Exception { > System.out.println("hi! from "+System.getProperty("java.vm.vendor")); > } > } > {boy@moon:~/tmp} /export/jdk1.6.0/bin/java classloadertest > Class.forName("hi", true, mycl1) = [class hi] > Class.forName("hi", true, mycl2) = [class hi] > mycl1.findLoadedClass(hi) = [class hi] > mycl2.findLoadedClass(hi) = [class hi] > {boy@moon:~/tmp} ~/harmony579850/bin/java classloadertest > Class.forName("hi", true, mycl1) = [class hi] > Class.forName("hi", true, mycl2) = [class hi] > mycl1.findLoadedClass(hi) = [class hi] > mycl2.findLoadedClass(hi) = [null] > {boy@moon:~/tmp} > Please note the "mycl2.findLoadedClass(hi) = ..." lines in outputs. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.