protected void define(byte[] bytes, final String name) {
//knownClasses.put(name, defineClass(name, bytes, 0, bytes.length));
Class cls = defineClass(name, bytes, 0, bytes.length);
+ //Class cls2 = defineClass(name, bytes, 0, bytes.length);
}
protected final Map<String,Class> knownClasses = new HashMap<String,Class>();
SunClassLoader sun = new SunClassLoader();
sun.loadMagic();
- Class cls = sun.loadClass("java/lang/Object");
+ //Class cls = sun.loadClass("java/lang/Object");
}
}
jpf-core.classpath=\
${jpf-core}/build/jpf-classes.jar;\
+ ${jpf-core}/build/asm-7.1.jar;\
${jpf-core}/build/examples
jpf-core.sourcepath=\
### PreciseRaceDetector
# we don't check for races in standard libraries
-race.exclude=java.*,javax.*,groovy.*,org.*
+race.exclude=java.*,javax.*
############################### 5. test part #############################
* limitations under the License.
*/
-public class Racer implements Runnable {\r
-\r
- int d = 42;\r
-\r
+public class Racer implements Runnable {
+
+ int d = 42;
+
@Override
- public void run () {\r
- doSomething(1001); // (1)\r
- d = 0; // (2)\r
- }\r
-\r
- public static void main (String[] args){\r
- Racer racer = new Racer();\r
- Thread t = new Thread(racer);\r
- t.start();\r
-\r
- doSomething(1000); // (3)\r
- int c = 420 / racer.d; // (4)\r
- System.out.println(c);\r
- }\r
- \r
- static void doSomething (int n) {\r
- // not very interesting..\r
- try { Thread.sleep(n); } catch (InterruptedException ix) {}\r
- }\r
-}\r
+ public void run () {
+ doSomething(1001); // (1)
+ d = 0; // (2)
+ }
+
+ public static void main (String[] args){
+ Racer racer = new Racer();
+ Thread t = new Thread(racer);
+ t.start();
+
+ doSomething(1000); // (3)
+ int c = 420 / racer.d; // (4)
+ System.out.println(c);
+ }
+
+ static void doSomething (int n) {
+ // not very interesting..
+ try { Thread.sleep(n); } catch (InterruptedException ix) {}
+ }
+}
ClassLoaderInfo cl = env.getClassLoaderInfo(objRef);
// determine whether that the corresponding class is already defined by this
- // classloader, if so, just return the already defined class!
+ // classloader, if so, this attempt is invalid, and loading throws a LinkageError
if (cl.getDefinedClassInfo(cname) != null) { // attempt to define twice
- return cl.getDefinedClassInfo(cname).getClassObjectRef();
+ env.throwException("java.lang.LinkageError");
+ return MJIEnv.NULL;
}
byte[] buffer = env.getByteArrayObject(bufferRef);
int sysObjRef = env.getSystemClassLoaderInfo().getClassLoaderObjectRef();
if (objRef != sysObjRef) {
- return defineClass0__Ljava_lang_String_2_3BII__Ljava_lang_Class_2
- (env, sysObjRef, nameRef, bufferRef, offset, length);
+ // Check if this class has been defined in the SystemClassLoader
+ ClassLoaderInfo cl = env.getSystemClassLoaderInfo();
+ String cname = env.getStringObject(nameRef);
+ if (cl.getDefinedClassInfo(cname) != null) {
+ ClassInfo ci = cl.getResolvedClassInfo(cname);
+ return ci.getClassObjectRef();
+ } else {
+ return defineClass0__Ljava_lang_String_2_3BII__Ljava_lang_Class_2
+ (env, sysObjRef, nameRef, bufferRef, offset, length);
+ }
}
env.throwException("java.lang.ClassNotFoundException");
return MJIEnv.NULL;