test/runtime/6626217/Loader2.java

Mon, 28 Jul 2014 15:06:38 -0700

author
fzhinkin
date
Mon, 28 Jul 2014 15:06:38 -0700
changeset 6997
dbb05f6d93c4
parent 0
f90c822e73f8
permissions
-rw-r--r--

8051344: JVM crashed in Compile::start() during method parsing w/ UseRTMDeopt turned on
Summary: call rtm_deopt() only if there were no compilation bailouts before.
Reviewed-by: kvn

aoqi@0 1 import java.io.ByteArrayInputStream;
aoqi@0 2 import java.io.FileInputStream;
aoqi@0 3 public class Loader2 extends ClassLoader {
aoqi@0 4 int _recur;
aoqi@0 5 public void print( String msg ) {
aoqi@0 6 for( int i=0; i<_recur; i++ )
aoqi@0 7 System.out.print(" ");
aoqi@0 8 System.out.println(">>Loader2>> "+msg);
aoqi@0 9 }
aoqi@0 10
aoqi@0 11 protected Class findClass2(String name) throws ClassNotFoundException {
aoqi@0 12 print("Fetching the implementation of "+name);
aoqi@0 13 int old = _recur;
aoqi@0 14 try {
aoqi@0 15 FileInputStream fi = new FileInputStream(name+".impl2");
aoqi@0 16 byte result[] = new byte[fi.available()];
aoqi@0 17 fi.read(result);
aoqi@0 18
aoqi@0 19 print("DefineClass1 on "+name);
aoqi@0 20 _recur++;
aoqi@0 21 Class clazz = defineClass(name, result, 0, result.length);
aoqi@0 22 _recur = old;
aoqi@0 23 print("Returning newly loaded class.");
aoqi@0 24 return clazz;
aoqi@0 25 } catch (Exception e) {
aoqi@0 26 _recur = old;
aoqi@0 27 print("Not found on disk.");
aoqi@0 28 // If we caught an exception, either the class was not found or
aoqi@0 29 // it was unreadable by our process.
aoqi@0 30 return null;
aoqi@0 31 //throw new ClassNotFoundException(e.toString());
aoqi@0 32 }
aoqi@0 33 }
aoqi@0 34
aoqi@0 35 protected synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException {
aoqi@0 36 // Attempt a disk load first
aoqi@0 37 Class c = findClass2(name);
aoqi@0 38 if( c == null ) {
aoqi@0 39 // check if the class has already been loaded
aoqi@0 40 print("Checking for prior loaded class "+name);
aoqi@0 41 c = findLoadedClass(name);
aoqi@0 42 print("Letting super-loader load "+name);
aoqi@0 43 int old = _recur;
aoqi@0 44 _recur++;
aoqi@0 45 c = super.loadClass(name, false);
aoqi@0 46 _recur=old;
aoqi@0 47 }
aoqi@0 48 if (resolve) { print("Resolving class "+name); resolveClass(c); }
aoqi@0 49 print("Returning clazz "+c.getClassLoader()+":"+name);
aoqi@0 50 return c;
aoqi@0 51 }
aoqi@0 52 }

mercurial