public void testTransformWithLTW() {
runTest("transform with LTW");
}
+
+
+ public void testTransformStaticMethodPreJava5() {
+ runTest("transform static method - preJ5");
+ }
+
+ public void testTransformStaticMethodPreJava5_2() {
+ runTest("transform static method - packages - preJ5");
+ }
// more complex code sequences...
public void testOtherTargeters() {
</run>
</ajc-test>
+
+ <ajc-test dir="features152/synchronization/transformed" title="transform static method - preJ5">
+ <compile files="Fifteen.java" options="-Xjoinpoints:synchronization -1.4">
+ </compile>
+ <run class="Fifteen">
+ <stderr>
+ <line text="Locking occurring at lock(lock(Object))"/>
+ <line text="Fifteen.java"/>
+ <line text="hello"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+
+ <ajc-test dir="features152/synchronization/transformed" title="transform static method - packages - preJ5">
+ <compile files="Sixteen.java" options="-Xjoinpoints:synchronization -1.4">
+ </compile>
+ <run class="a.b.c.d.Sixteen">
+ <stderr>
+ <line text="Locking occurring at lock(lock(Object))"/>
+ <line text="Sixteen.java"/>
+ <line text="hello"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
<ajc-test dir="features152/synchronization" title="obtaining locked object through getArgs">
<compile files="LockingWithTJP.java" options="-Xjoinpoints:synchronization">
</compile>
parttwo.append(InstructionFactory.MONITORENTER);
String fieldname = synchronizedMethod.getEnclosingClass().allocateField("class$");
- System.err.println("Going to use field name "+fieldname);
Field f = new FieldGen(Modifier.STATIC | Modifier.PRIVATE,
Type.getType(Class.class),fieldname,synchronizedMethod.getEnclosingClass().getConstantPoolGen()).getField();
synchronizedMethod.getEnclosingClass().addField(f, null);
// 25: invokevirtual #52; //Method java/lang/Throwable.getMessage:()Ljava/lang/String;
// 28: invokespecial #54; //Method java/lang/NoClassDefFoundError."<init>":(Ljava/lang/String;)V
// 31: athrow
- prepend.append(fact.createGetStatic("C", fieldname, Type.getType(Class.class)));
+ String name = synchronizedMethod.getEnclosingClass().getName();
+
+ prepend.append(fact.createGetStatic(name, fieldname, Type.getType(Class.class)));
prepend.append(InstructionFactory.createDup(1));
prepend.append(InstructionFactory.createBranchInstruction(Constants.IFNONNULL, parttwo.getStart()));
prepend.append(InstructionFactory.POP);
- prepend.append(fact.createConstant("C"));
+ prepend.append(fact.createConstant(name));
InstructionHandle tryInstruction = prepend.getEnd();
prepend.append(fact.createInvoke("java.lang.Class", "forName", clazzType,new Type[]{ Type.getType(String.class)}, Constants.INVOKESTATIC));
InstructionHandle catchInstruction = prepend.getEnd();