Bug 432866 - [otre] migrate the dynamic weaver to ASM 5.0.1
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/JDTLaunchingAdaptor.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/JDTLaunchingAdaptor.java
index 3fb5413..aa670df 100644
--- a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/JDTLaunchingAdaptor.java
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/JDTLaunchingAdaptor.java
@@ -88,7 +88,8 @@
for (int i = 0; i < origEntries.length; i++)
{
IPath entryPath = origEntries[i].getPath();
- if (OTREContainer.BYTECODE_LIBRARY_PATH.equals(entryPath))
+ if (OTREContainer.BYTECODE_LIBRARY_PATH.length == 1
+ && OTREContainer.BYTECODE_LIBRARY_PATH[0].equals(entryPath))
hasBCEL = true;
else if (otreMinJarPath.equals(entryPath))
hasOTRE_min = true;
@@ -98,8 +99,11 @@
IRuntimeClasspathEntry entry;
if (!hasBCEL) {
- entry = JavaRuntime.newArchiveRuntimeClasspathEntry(OTREContainer.BYTECODE_LIBRARY_PATH);
- result.add(entry);
+ int l = OTREContainer.BYTECODE_LIBRARY_PATH.length;
+ for (int i = 0; i < l; i++) {
+ entry = JavaRuntime.newArchiveRuntimeClasspathEntry(OTREContainer.BYTECODE_LIBRARY_PATH[i]);
+ result.add(entry);
+ }
}
if (!hasOTRE_min) {
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainer.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainer.java
index 102562e..50a2516 100644
--- a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainer.java
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainer.java
@@ -56,7 +56,7 @@
private static IPath OTRE_AGENT_JAR_PATH;
private static IPath OTEQUINOX_AGENT_JAR_PATH;
- public static IPath BYTECODE_LIBRARY_PATH; // will be initialized in {@link findBytecodeLib(BundleContext,boolean)}
+ public static IPath[] BYTECODE_LIBRARY_PATH; // will be initialized in {@link findBytecodeLib(BundleContext,boolean)}
// details of this container: name and hosting plugin:
private static final IPath OTRE_CONTAINER_PATH = new Path(OTRE_CONTAINER_NAME);
@@ -71,8 +71,8 @@
private static final String BCEL_BUNDLE_NAME = "org.apache.bcel"; //$NON-NLS-1$
private static final String BCEL_VERSION_RANGE = "[5.2.0,5.3.0)"; //$NON-NLS-1$
- private static final String ASM_BUNDLE_NAME = "org.objectweb.asm"; //$NON-NLS-1$
- private static final String ASM_VERSION_RANGE = "[3.3.1,4.0.0)"; //$NON-NLS-1$
+ private static final String[] ASM_BUNDLE_NAMES = { "org.objectweb.asm", "org.objectweb.asm.tree", "org.objectweb.asm.commons" }; //$NON-NLS-1$
+ private static final String ASM_VERSION_RANGE = "[5.0.1,6.0.0)"; //$NON-NLS-1$
private IClasspathEntry[] _cpEntries;
@@ -215,11 +215,23 @@
if (ref == null)
throw new IllegalStateException("Cannot connect to PackageAdmin"); //$NON-NLS-1$
PackageAdmin packageAdmin = context.getService(ref);
- String bundleName = useDynamicWeaving ? ASM_BUNDLE_NAME : BCEL_BUNDLE_NAME;
- String bundleVersionRange = useDynamicWeaving ? ASM_VERSION_RANGE : BCEL_VERSION_RANGE;
- for (Bundle bundle : packageAdmin.getBundles(bundleName, bundleVersionRange)) {
- BYTECODE_LIBRARY_PATH = new Path(FileLocator.toFileURL(bundle.getEntry("/")).getFile()); //$NON-NLS-1$
+ if (useDynamicWeaving) {
+ BYTECODE_LIBRARY_PATH = new IPath[ASM_BUNDLE_NAMES.length];
+ int i = 0;
+ for (String bundleName : ASM_BUNDLE_NAMES) {
+ for (Bundle bundle : packageAdmin.getBundles(bundleName, ASM_VERSION_RANGE)) {
+ BYTECODE_LIBRARY_PATH[i++] = new Path(FileLocator.toFileURL(bundle.getEntry("/")).getFile()); //$NON-NLS-1$
+ break;
+ }
+ }
return;
+ } else {
+ String bundleName = BCEL_BUNDLE_NAME;
+ String bundleVersionRange = BCEL_VERSION_RANGE;
+ for (Bundle bundle : packageAdmin.getBundles(bundleName, bundleVersionRange)) {
+ BYTECODE_LIBRARY_PATH = new IPath[] { new Path(FileLocator.toFileURL(bundle.getEntry("/")).getFile()) }; //$NON-NLS-1$
+ return;
+ }
}
throw new RuntimeException("bytecode libarary not found, useDynamicWeaving="+useDynamicWeaving); //$NON-NLS-1$
}
diff --git a/plugins/org.eclipse.objectteams.otredyn/META-INF/MANIFEST.MF b/plugins/org.eclipse.objectteams.otredyn/META-INF/MANIFEST.MF
index 4732fce..4fcd432 100644
--- a/plugins/org.eclipse.objectteams.otredyn/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.objectteams.otredyn/META-INF/MANIFEST.MF
@@ -15,4 +15,6 @@
org.eclipse.objectteams.otredyn.util
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ClassPath: .
-Require-Bundle: org.objectweb.asm;bundle-version="3.3.1"
+Require-Bundle: org.objectweb.asm;bundle-version="5.0.1",
+ org.objectweb.asm.tree;bundle-version="5.0.1",
+ org.objectweb.asm.commons;bundle-version="5.0.1"
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AbstractCreateDispatchCodeAdapter.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AbstractCreateDispatchCodeAdapter.java
index 449222e..b6fd1ef 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AbstractCreateDispatchCodeAdapter.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AbstractCreateDispatchCodeAdapter.java
@@ -71,7 +71,8 @@
instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
ClassNames.TEAM_MANAGER_SLASH, ConstantMembers.getTeams.getName(),
- ConstantMembers.getTeams.getSignature()));
+ ConstantMembers.getTeams.getSignature(),
+ false));
instructions.add(createInstructionsToCheackTeams(method));
@@ -99,7 +100,8 @@
.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
ClassNames.TEAM_MANAGER_SLASH,
ConstantMembers.getCallinIds.getName(),
- ConstantMembers.getCallinIds.getSignature()));
+ ConstantMembers.getCallinIds.getSignature(),
+ false));
instructions.add(createLoadIntConstant(boundMethodId));
args = Type.getArgumentTypes(method.desc);
@@ -108,9 +110,10 @@
instructions.add(getBoxedArguments(args));
instructions.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE,
- ClassNames.ITEAM_SLASH, ConstantMembers.callAllBindingsTeam
- .getName(), ConstantMembers.callAllBindingsTeam
- .getSignature()));
+ ClassNames.ITEAM_SLASH,
+ ConstantMembers.callAllBindingsTeam.getName(),
+ ConstantMembers.callAllBindingsTeam.getSignature(),
+ true));
Type returnType = Type.getReturnType(method.desc);
instructions.add(getUnboxingInstructionsForReturnValue(returnType));
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AbstractTransformableClassNode.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AbstractTransformableClassNode.java
index e964657..13d52bb 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AbstractTransformableClassNode.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AbstractTransformableClassNode.java
@@ -36,9 +36,11 @@
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.TypeInsnNode;
+import static org.eclipse.objectteams.otredyn.bytecode.asm.AsmBoundClass.ASM_API;
+
/**
* Every class, that wants to manipulate the bytecode of a class
- * with the ASM Trea API, have to inherit from this class and do
+ * with the ASM Tree API, have to inherit from this class and do
* the transformations in the method transform().
* Additionally the class provides util methods to
* manipulate the bytecode
@@ -46,6 +48,10 @@
*/
public abstract class AbstractTransformableClassNode extends ClassNode {
+ public AbstractTransformableClassNode() {
+ super(ASM_API);
+ }
+
/**
* Returns instructions, that are needed to pack all arguments of a method
* in an {@link Object} Array
@@ -192,7 +198,7 @@
"java/lang/System", "out", "Ljava/io/PrintStream;"));
instructions.add(new LdcInsnNode(message));
instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,
- "java/io/PrintStream", "println", "(Ljava/lang/String;)V"));
+ "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false));
return instructions;
}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddAfterClassLoadingHook.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddAfterClassLoadingHook.java
index 9398b26..cbc2bc9 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddAfterClassLoadingHook.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddAfterClassLoadingHook.java
@@ -17,7 +17,6 @@
import org.eclipse.objectteams.otredyn.bytecode.AbstractBoundClass;
import org.eclipse.objectteams.otredyn.transformer.names.ClassNames;
-import org.objectweb.asm.ClassAdapter;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Type;
@@ -29,6 +28,8 @@
import static org.objectweb.asm.Opcodes.INVOKESTATIC;
import static org.objectweb.asm.Opcodes.RETURN;
+import static org.eclipse.objectteams.otredyn.bytecode.asm.AsmBoundClass.ASM_API;
+
/**
* This adapter adds static initialization that gives the TeamManager
@@ -41,7 +42,7 @@
* @author stephan
*
*/
-public class AddAfterClassLoadingHook extends ClassAdapter {
+public class AddAfterClassLoadingHook extends ClassVisitor {
// the method to look for or add:
private static final String CLINIT_NAME = "<clinit>";
@@ -56,7 +57,7 @@
AbstractBoundClass clazz;
public AddAfterClassLoadingHook(ClassVisitor arg0, AbstractBoundClass clazz) {
- super(arg0);
+ super(ASM_API, arg0);
this.clazz = clazz;
}
@@ -66,7 +67,7 @@
// clinit already exists, add our statement to the front:
this.needToAdd = false;
final MethodVisitor clinit = cv.visitMethod(access, name, desc, null, null);
- return new AdviceAdapter(clinit, access, name, desc) {
+ return new AdviceAdapter(this.api, clinit, access, name, desc) {
@Override
protected void onMethodEnter() {
createHookCall(clinit);
@@ -98,6 +99,6 @@
clinit.visitLdcInsn(Type.getObjectType(clazz.getName().replace('.', '/')));
else
clinit.visitInsn(Opcodes.ACONST_NULL);
- clinit.visitMethodInsn(INVOKESTATIC, TARGET_CLASS_NAME, TARGET_METHOD_NAME, TARGET_METHOD_DESC);
+ clinit.visitMethodInsn(INVOKESTATIC, TARGET_CLASS_NAME, TARGET_METHOD_NAME, TARGET_METHOD_DESC, false);
}
}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddEmptyMethodAdapter.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddEmptyMethodAdapter.java
index 56a2a55..63c62d4 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddEmptyMethodAdapter.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddEmptyMethodAdapter.java
@@ -16,18 +16,19 @@
**********************************************************************/
package org.eclipse.objectteams.otredyn.bytecode.asm;
-import org.objectweb.asm.ClassAdapter;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
+import static org.eclipse.objectteams.otredyn.bytecode.asm.AsmBoundClass.ASM_API;
+
/**
* This class adds an method only with a return statement
* to the bytecode of a class with the ASM Core API
* @author Oliver Frank
*/
-class AddEmptyMethodAdapter extends ClassAdapter {
+class AddEmptyMethodAdapter extends ClassVisitor {
private int access;
private String name;
@@ -39,7 +40,7 @@
public AddEmptyMethodAdapter(ClassVisitor cv, String name, int access,
String desc, String[] exceptions, String signature,
int maxLocals) {
- super(cv);
+ super(ASM_API, cv);
this.access = access;
this.desc = desc;
this.exceptions = exceptions;
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddFieldAdapter.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddFieldAdapter.java
index cd1141e..4d9982e 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddFieldAdapter.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddFieldAdapter.java
@@ -16,16 +16,17 @@
**********************************************************************/
package org.eclipse.objectteams.otredyn.bytecode.asm;
-import org.objectweb.asm.ClassAdapter;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
+import static org.eclipse.objectteams.otredyn.bytecode.asm.AsmBoundClass.ASM_API;
+
/**
* Adds an field to the bytecode of a class
* @author Oliver Frank
*/
-class AddFieldAdapter extends ClassAdapter {
+class AddFieldAdapter extends ClassVisitor {
private int access;
private String name;
@@ -33,7 +34,7 @@
public AddFieldAdapter(ClassVisitor cv, String name, int access,
String desc) {
- super(cv);
+ super(ASM_API, cv);
this.access = access;
this.desc = desc;
this.name = name;
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddGlobalTeamActivationAdapter.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddGlobalTeamActivationAdapter.java
index 711047a..a8d8ebe 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddGlobalTeamActivationAdapter.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddGlobalTeamActivationAdapter.java
@@ -23,7 +23,6 @@
import java.util.List;
import org.eclipse.objectteams.otredyn.transformer.names.ClassNames;
-import org.objectweb.asm.ClassAdapter;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Label;
@@ -31,13 +30,15 @@
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.commons.AdviceAdapter;
+import static org.eclipse.objectteams.otredyn.bytecode.asm.AsmBoundClass.ASM_API;
+
/**
* This adapter adds some instructions to the front of the main-method.
* These instructions will instantiate and globally activate all teams
* that are listed in the team config file.
* The team config file is specified via the <code>ot.teamconfig</code> property.
*/
-public class AddGlobalTeamActivationAdapter extends ClassAdapter {
+public class AddGlobalTeamActivationAdapter extends ClassVisitor {
/** Initialized from property <tt>ot.teamconfig</tt>. */
private final static String TEAM_CONFIG_FILE = System.getProperty("ot.teamconfig");
@@ -47,7 +48,7 @@
private static boolean done = false;
private AddGlobalTeamActivationAdapter(ClassVisitor cv) {
- super(cv);
+ super(ASM_API, cv);
}
/**
@@ -68,7 +69,7 @@
if (!done && isMainMethod(name, desc, access)) {
done = true;
final MethodVisitor methodVisitor = cv.visitMethod(access, name, desc, null, null);
- return new AdviceAdapter(methodVisitor, access, name, desc) {
+ return new AdviceAdapter(this.api, methodVisitor, access, name, desc) {
@Override
protected void onMethodEnter() {
List<String> teams = getTeamsFromConfigFile();
@@ -82,9 +83,9 @@
methodVisitor.visitTypeInsn(Opcodes.NEW, aTeamSlash);
// .activate(Team.ALL_THREADS):
methodVisitor.visitInsn(Opcodes.DUP);
- methodVisitor.visitMethodInsn(Opcodes.INVOKESPECIAL, aTeamSlash, "<init>", "()V");
+ methodVisitor.visitMethodInsn(Opcodes.INVOKESPECIAL, aTeamSlash, "<init>", "()V", false);
methodVisitor.visitFieldInsn(Opcodes.GETSTATIC, ClassNames.TEAM_SLASH, "ALL_THREADS", "Ljava/lang/Thread;");
- methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, aTeamSlash, "activate", "(Ljava/lang/Thread;)V");
+ methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, aTeamSlash, "activate", "(Ljava/lang/Thread;)V", false);
methodVisitor.visitLabel(end=new Label());
methodVisitor.visitJumpInsn(Opcodes.GOTO, after=new Label());
@@ -95,7 +96,7 @@
methodVisitor.visitInsn(Opcodes.POP); // discard the exception
methodVisitor.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/System", "err", "Ljava/io/PrintStream;");
methodVisitor.visitLdcInsn("Config error: Team class '"+aTeam+ "' in config file '"+ TEAM_CONFIG_FILE+"' can not be found!");
- methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V");
+ methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false);
methodVisitor.visitJumpInsn(Opcodes.GOTO, after);
methodVisitor.visitTryCatchBlock(start, end, typeHandler, "java/lang/ClassNotFoundException");
methodVisitor.visitTryCatchBlock(start, end, typeHandler, "java/lang/NoClassDefFoundError");
@@ -106,7 +107,7 @@
methodVisitor.visitInsn(Opcodes.POP); // discard the exception
methodVisitor.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/System", "err", "Ljava/io/PrintStream;");
methodVisitor.visitLdcInsn("Activation failed: Team class '"+aTeam+ "' has no default constuctor!");
- methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V");
+ methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false);
methodVisitor.visitTryCatchBlock(start, end, ctorHandler, "java/lang/NoSuchMethodError");
methodVisitor.visitLabel(after);
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddImplicitActivationAdapter.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddImplicitActivationAdapter.java
index 6b7ea80..a01f972 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddImplicitActivationAdapter.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddImplicitActivationAdapter.java
@@ -17,13 +17,14 @@
import org.eclipse.objectteams.otredyn.transformer.names.ClassNames;
import org.eclipse.objectteams.otredyn.transformer.names.ConstantMembers;
-import org.objectweb.asm.ClassAdapter;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.commons.AdviceAdapter;
import org.objectweb.asm.Opcodes;
+import static org.eclipse.objectteams.otredyn.bytecode.asm.AsmBoundClass.ASM_API;
+
/**
* This visitor adds calls to _OT$implicitlyActivate and _OT$implicitlyDeactivate
* into all relevant methods as configured by
@@ -32,7 +33,7 @@
* <li>annotation {@link org.objectteams.ImplicitTeamActivation}.
* </ul>
*/
-public class AddImplicitActivationAdapter extends ClassAdapter {
+public class AddImplicitActivationAdapter extends ClassVisitor {
public static final Object ANNOTATION_IMPLICIT_ACTIVATION = 'L'+ClassNames.IMPLICIT_ACTIVATION+';';
@@ -60,7 +61,7 @@
private AsmBoundClass clazz;
public AddImplicitActivationAdapter(ClassVisitor cv, AsmBoundClass clazz) {
- super(cv);
+ super(ASM_API, cv);
this.clazz = clazz;
}
@@ -70,31 +71,31 @@
if (isCandidateForImplicitActivation(name, desc, access)) {
final MethodVisitor methodVisitor = cv.visitMethod(access, name, desc, null, null);
final String enclTeamDesc = clazz.isRole() ? 'L'+clazz.getEnclosingClass().getName().replace('.', '/')+';' : null;
- return new AdviceAdapter(methodVisitor, access, name, desc) {
+ return new AdviceAdapter(this.api, methodVisitor, access, name, desc) {
@Override
protected void onMethodEnter() {
if (clazz.isTeam()) {
methodVisitor.visitIntInsn(Opcodes.ALOAD, 0);
- methodVisitor.visitMethodInsn(INVOKEINTERFACE, TARGET_CLASS_NAME, IMPLICIT_ACTIVATE_METHOD_NAME, METHOD_DESC);
+ methodVisitor.visitMethodInsn(INVOKEINTERFACE, TARGET_CLASS_NAME, IMPLICIT_ACTIVATE_METHOD_NAME, METHOD_DESC, true);
}
if (clazz.isRole()) {
// TODO(SH): respect nesting depth (this$n)
methodVisitor.visitIntInsn(Opcodes.ALOAD, 0);
methodVisitor.visitFieldInsn(Opcodes.GETFIELD, clazz.getName().replace('.', '/'), "this$0", enclTeamDesc);
- methodVisitor.visitMethodInsn(INVOKEINTERFACE, TARGET_CLASS_NAME, IMPLICIT_ACTIVATE_METHOD_NAME, METHOD_DESC);
+ methodVisitor.visitMethodInsn(INVOKEINTERFACE, TARGET_CLASS_NAME, IMPLICIT_ACTIVATE_METHOD_NAME, METHOD_DESC, true);
}
}
@Override
protected void onMethodExit(int opcode) {
if (clazz.isTeam()) {
methodVisitor.visitIntInsn(Opcodes.ALOAD, 0);
- methodVisitor.visitMethodInsn(INVOKEINTERFACE, TARGET_CLASS_NAME, IMPLICIT_DEACTIVATE_METHOD_NAME, METHOD_DESC);
+ methodVisitor.visitMethodInsn(INVOKEINTERFACE, TARGET_CLASS_NAME, IMPLICIT_DEACTIVATE_METHOD_NAME, METHOD_DESC, true);
}
if (clazz.isRole()) {
// TODO(SH): respect nesting depth (this$n)
methodVisitor.visitIntInsn(Opcodes.ALOAD, 0);
methodVisitor.visitFieldInsn(Opcodes.GETFIELD, clazz.getName().replace('.', '/'), "this$0", enclTeamDesc);
- methodVisitor.visitMethodInsn(INVOKEINTERFACE, TARGET_CLASS_NAME, IMPLICIT_DEACTIVATE_METHOD_NAME, METHOD_DESC);
+ methodVisitor.visitMethodInsn(INVOKEINTERFACE, TARGET_CLASS_NAME, IMPLICIT_DEACTIVATE_METHOD_NAME, METHOD_DESC, true);
}
if (clazz.isTeam() || clazz.isRole())
methodVisitor.visitMaxs(0, 0);
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddInterfaceAdapter.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddInterfaceAdapter.java
index 6220908..d58f1e7 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddInterfaceAdapter.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AddInterfaceAdapter.java
@@ -16,21 +16,22 @@
**********************************************************************/
package org.eclipse.objectteams.otredyn.bytecode.asm;
-import org.objectweb.asm.ClassAdapter;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
+import static org.eclipse.objectteams.otredyn.bytecode.asm.AsmBoundClass.ASM_API;
+
/**
* Adds an interface to the bytecode of a class
* @author Oliver Frank
*
*/
-public class AddInterfaceAdapter extends ClassAdapter{
+public class AddInterfaceAdapter extends ClassVisitor {
private String interfaceName;
public AddInterfaceAdapter(ClassVisitor cv, String interfaceName) {
- super(cv);
+ super(ASM_API, cv);
this.interfaceName = interfaceName;
}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmBoundClass.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmBoundClass.java
index 31afa82..3bebdf6 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmBoundClass.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmBoundClass.java
@@ -18,9 +18,9 @@
import org.eclipse.objectteams.otredyn.bytecode.AbstractBoundClass;
import org.eclipse.objectteams.otredyn.bytecode.AbstractTeam;
-import org.eclipse.objectteams.otredyn.bytecode.Binding;
import org.eclipse.objectteams.otredyn.bytecode.IBytecodeProvider;
import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.Opcodes;
/**
* This class implements the bytecode parsing for {@link AbstractBoundClass}.
@@ -28,6 +28,8 @@
* @author Oliver Frank
*/
abstract class AsmBoundClass extends AbstractTeam {
+
+ public static final int ASM_API = Opcodes.ASM5;
private boolean parsed;
private IBytecodeProvider bytecodeProvider;
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmClassVisitor.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmClassVisitor.java
index a54d420..a89a2b0 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmClassVisitor.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmClassVisitor.java
@@ -25,21 +25,24 @@
import org.eclipse.objectteams.otredyn.bytecode.asm.Attributes.OTSpecialAccessAttribute;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Attribute;
+import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.commons.EmptyVisitor;
+
+import static org.eclipse.objectteams.otredyn.bytecode.asm.AsmBoundClass.ASM_API;
/**
* This class is used to parse the bytecode of a class.
* It sets the informations, that are parsed, in the {@link AsmBoundClass}
* @author Oliver Frank
*/
-class AsmClassVisitor extends EmptyVisitor {
+class AsmClassVisitor extends ClassVisitor {
private AsmBoundClass clazz;
public AsmClassVisitor(AsmBoundClass clazz) {
+ super(ASM_API);
this.clazz = clazz;
}
@@ -62,7 +65,7 @@
clazz.addMethod(name, desc, (access & Opcodes.ACC_STATIC) != 0, (access & (Opcodes.ACC_PUBLIC|Opcodes.ACC_PROTECTED|Opcodes.ACC_PRIVATE)));
if (clazz.isTeam() || clazz.isRole())
// check for method annotation ImplicitTeamActivation:
- return new EmptyVisitor() {
+ return new MethodVisitor(this.api) {
@Override
public AnnotationVisitor visitAnnotation(String annDesc, boolean visible) {
if (annDesc.equals(AddImplicitActivationAdapter.ANNOTATION_IMPLICIT_ACTIVATION))
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmTypeHelper.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmTypeHelper.java
index 5af508d..d59fcb1 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmTypeHelper.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmTypeHelper.java
@@ -31,7 +31,7 @@
String methodName = primitiveType.getClassName() + "Value";
String desc = Type.getMethodDescriptor(primitiveType, new Type[] {});
- return new MethodInsnNode(Opcodes.INVOKEVIRTUAL, objectType, methodName, desc);
+ return new MethodInsnNode(Opcodes.INVOKEVIRTUAL, objectType, methodName, desc, false);
}
public static String getObjectType(Type primitiveType) {
@@ -74,6 +74,6 @@
return new InsnNode(Opcodes.NOP);
String desc = Type.getMethodDescriptor(Type.getObjectType(className), new Type[] {type});
- return new MethodInsnNode(Opcodes.INVOKESTATIC, className, "valueOf", desc);
+ return new MethodInsnNode(Opcodes.INVOKESTATIC, className, "valueOf", desc, false);
}
}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateAddRemoveRoleMethod.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateAddRemoveRoleMethod.java
index 4080b82..195821e 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateAddRemoveRoleMethod.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateAddRemoveRoleMethod.java
@@ -54,7 +54,7 @@
// set.add(role);
method.instructions.add(new IntInsnNode(Opcodes.ALOAD, 3));
method.instructions.add(new IntInsnNode(Opcodes.ALOAD, 1));
- method.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, ClassNames.HASH_SET_SLASH, "add", "(Ljava/lang/Object;)Z"));
+ method.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, ClassNames.HASH_SET_SLASH, "add", "(Ljava/lang/Object;)Z", false));
method.instructions.add(new InsnNode(Opcodes.POP));
LabelNode jumpToEnd = new LabelNode();
@@ -64,7 +64,7 @@
// set.remove(role);
method.instructions.add(new IntInsnNode(Opcodes.ALOAD, 3));
method.instructions.add(new IntInsnNode(Opcodes.ALOAD, 1));
- method.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, ClassNames.HASH_SET_SLASH, "remove", "(Ljava/lang/Object;)Z"));
+ method.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, ClassNames.HASH_SET_SLASH, "remove", "(Ljava/lang/Object;)Z", false));
method.instructions.add(new InsnNode(Opcodes.POP));
method.instructions.add(jumpToEnd);
@@ -93,7 +93,7 @@
instructions.add(new IntInsnNode(Opcodes.ALOAD, 0));
instructions.add(new TypeInsnNode(Opcodes.NEW, ClassNames.HASH_SET_SLASH));
instructions.add(new InsnNode(Opcodes.DUP));
- instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, ClassNames.HASH_SET_SLASH, "<init>", "()V"));
+ instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, ClassNames.HASH_SET_SLASH, "<init>", "()V", false));
instructions.add(new IntInsnNode(Opcodes.ASTORE, targetLocal));
instructions.add(new IntInsnNode(Opcodes.ALOAD, targetLocal));
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateCallAllBindingsCallInOrgMethod.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateCallAllBindingsCallInOrgMethod.java
index 6dfb191..b2273c5 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateCallAllBindingsCallInOrgMethod.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateCallAllBindingsCallInOrgMethod.java
@@ -157,7 +157,7 @@
// catch (SneakyException e) { e.rethrow(); }
LabelNode catchSneaky = new LabelNode();
instructions.add(catchSneaky);
- instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, ClassNames.SNEAKY_EXCEPTION_SLASH, ClassNames.RETHROW_SELECTOR, ClassNames.RETHROW_SIGNATURE));
+ instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, ClassNames.SNEAKY_EXCEPTION_SLASH, ClassNames.RETHROW_SELECTOR, ClassNames.RETHROW_SIGNATURE, false));
// never reached, just to please the verifier:
Type returnType = Type.getReturnType(method.getSignature());
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateSwitchForAccessAdapter.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateSwitchForAccessAdapter.java
index adebbf2..9d47646 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateSwitchForAccessAdapter.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateSwitchForAccessAdapter.java
@@ -58,13 +58,14 @@
// put "caller".getClass() on the stack
method.instructions.add(new IntInsnNode(Opcodes.ALOAD,
getFirstArgIndex() + 3));
- method.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/lang/Object", "getClass", "()Ljava/lang/Class;"));
+ method.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/lang/Object", "getClass", "()Ljava/lang/Class;", false));
// call "getMemberId(accessId, callerClass)
method.instructions
.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
ClassNames.TEAM_MANAGER_SLASH,
ConstantMembers.getMemberId.getName(),
- ConstantMembers.getMemberId.getSignature()));
+ ConstantMembers.getMemberId.getSignature(),
+ false));
}
@Override
@@ -75,7 +76,7 @@
method.instructions.add(new IntInsnNode(Opcodes.ILOAD, getFirstArgIndex())); // accessId
method.instructions.add(new LdcInsnNode(clazz.getName())); // current class
method.instructions.add(new LdcInsnNode("decapsulating access")); // access reason
- method.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, "org/objectteams/NoSuchMethodError", "<init>", "(ILjava/lang/String;Ljava/lang/String;)V"));
+ method.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, "org/objectteams/NoSuchMethodError", "<init>", "(ILjava/lang/String;Ljava/lang/String;)V", false));
method.instructions.add(new InsnNode(Opcodes.ATHROW));
} else {
Type[] args = Type.getArgumentTypes(method.desc);
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/MultiClassAdapter.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/MultiClassAdapter.java
index 0b0bcda..0a05a66 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/MultiClassAdapter.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/MultiClassAdapter.java
@@ -19,23 +19,24 @@
import java.util.ArrayList;
import java.util.List;
-import org.objectweb.asm.ClassAdapter;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
+import static org.eclipse.objectteams.otredyn.bytecode.asm.AsmBoundClass.ASM_API;
+
/**
* This class is needed to make it possible, that many
* ClassAdpters can manipulate the bytecode in one run.
* It just delegates all method calls to the concrete Adapters.
* @author Oliver Frank
*/
-class MultiClassAdapter extends ClassAdapter {
+class MultiClassAdapter extends ClassVisitor {
private List<ClassVisitor> visitors;
private ClassVisitor toplevelVisitor;
public MultiClassAdapter(ClassVisitor v) {
- super(v);
+ super(ASM_API, v);
this.visitors = new ArrayList<ClassVisitor>();
}
diff --git a/releng/map/otdt.map.in b/releng/map/otdt.map.in
index 1a2304a..699e43a 100644
--- a/releng/map/otdt.map.in
+++ b/releng/map/otdt.map.in
@@ -42,6 +42,10 @@
!** Consume BCEL from Orbit: **!
plugin@org.apache.bcel,5.2.0=p2IU,id=org.apache.bcel,version=5.2.0.v201005080400,repository=http://download.eclipse.org/tools/orbit/downloads/drops/R20120526062928/repository
+!** ASM from Orbit: **!
+plugin@org.objectweb.asm,5.0.1=p2IU,id=org.objectweb.asm=5.0.1.v201404071650,repository=http://download.eclipse.org/tools/orbit/downloads/drops/I20140407192103/repository/
+plugin@org.objectweb.asm.tree,5.0.1=p2IU,id=org.objectweb.asm.tree=5.0.1.v201404071650,repository=http://download.eclipse.org/tools/orbit/downloads/drops/I20140407192103/repository/
+plugin@org.objectweb.asm.commons,5.0.1=p2IU,id=org.objectweb.asm.commons=5.0.1.v201404071650,repository=http://download.eclipse.org/tools/orbit/downloads/drops/I20140407192103/repository/
!========== JDT/UI: ==========!
plugin@org.eclipse.jdt.ui=GIT,tag=@SDK_QUALIFIER@,repo=git://git.eclipse.org/gitroot/jdt/eclipse.jdt.ui.git,path=org.eclipse.jdt.ui
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/AbstractOTJLDTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/AbstractOTJLDTest.java
index 29c6094..4572e70 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/AbstractOTJLDTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/AbstractOTJLDTest.java
@@ -112,14 +112,16 @@
super(name);
}
- /** Add otre and bcel to the class path. */
+ /** Add otre and (bcel or asm) to the class path. */
@Override
protected String[] getDefaultClassPaths() {
String[] defaults = super.getDefaultClassPaths();
int len = defaults.length;
- System.arraycopy(defaults, 0, defaults=new String[len+2], 0, len);
+ int len2 = ClasspathUtil.BYTECODE_LIB_JAR_PATH.length;
+ System.arraycopy(defaults, 0, defaults=new String[len+1+len2], 0, len);
defaults[len] = new Path(ClasspathUtil.OTRE_PATH).toString();
- defaults[len+1] = ClasspathUtil.BYTECODE_LIB_JAR_PATH.toString();
+ for (int i=0; i<len2; i++)
+ defaults[len+1+i] = ClasspathUtil.BYTECODE_LIB_JAR_PATH[i].toString();
return defaults;
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/src/org/eclipse/objectteams/otdt/tests/ClasspathUtil.java b/testplugins/org.eclipse.objectteams.otdt.tests/src/org/eclipse/objectteams/otdt/tests/ClasspathUtil.java
index 98edf98..a929455 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/src/org/eclipse/objectteams/otdt/tests/ClasspathUtil.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/src/org/eclipse/objectteams/otdt/tests/ClasspathUtil.java
@@ -32,7 +32,7 @@
public static final String OTDT_PATH = JavaCore.getClasspathVariable(OTDTPlugin.OTDT_INSTALLDIR).toOSString();
public static final String OTRE_MIN_JAR_PATH;
public static final String OTAGENT_JAR_PATH;
- public static final IPath BYTECODE_LIB_JAR_PATH = OTREContainer.BYTECODE_LIBRARY_PATH;
+ public static final IPath[] BYTECODE_LIB_JAR_PATH = OTREContainer.BYTECODE_LIBRARY_PATH;
static {
if (CallinImplementorDyn.DYNAMIC_WEAVING) {