Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2018-02-10 19:27:41 +0000
committerStephan Herrmann2018-02-11 12:17:45 +0000
commit03e883dd68bda16afbdbb284265d846f16697f8a (patch)
tree253bac921d9779ae846fa78699998f4953b25ac1
parented5505e778ce1adab2728185fe92721d1de1773d (diff)
downloadorg.eclipse.objectteams-03e883dd68bda16afbdbb284265d846f16697f8a.tar.gz
org.eclipse.objectteams-03e883dd68bda16afbdbb284265d846f16697f8a.tar.xz
org.eclipse.objectteams-03e883dd68bda16afbdbb284265d846f16697f8a.zip
Bug 530914 - [otdre] Wrong kind of super-call in callOrig where super is
in fact not woven. - more systematically respect isSuperWeavable() during weaving. Cherry-pick of commit ec758b32eb41b03fcb7cd645811b0ab5f2703858
-rw-r--r--plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/AbstractBoundClass.java15
-rw-r--r--plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmWritableBoundClass.java30
2 files changed, 32 insertions, 13 deletions
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/AbstractBoundClass.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/AbstractBoundClass.java
index 605e319cd..fd84a999d 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/AbstractBoundClass.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/AbstractBoundClass.java
@@ -458,6 +458,21 @@ public abstract class AbstractBoundClass implements IBoundClass {
}
/**
+ * Returns the internal name of the super class of this class IFF that super class is weavable,
+ * otherwise it returns {@code null}.
+ * It parses the bytecode, if that has not already been done
+ * @return
+ */
+ public String getInternalWeavableSuperClassName() {
+ if (!isSuperWeavable())
+ return null;
+ parseBytecode();
+ return internalSuperClassName;
+ }
+
+ protected abstract boolean isSuperWeavable();
+
+ /**
* Returns the internal name of this class
* @return
*/
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmWritableBoundClass.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmWritableBoundClass.java
index 3fbb00bbc..e10148e19 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmWritableBoundClass.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmWritableBoundClass.java
@@ -63,6 +63,7 @@ class AsmWritableBoundClass extends AsmBoundClass {
private boolean isFirstTransformation = true;
private boolean isTransformationActive;
+ private Boolean superIsWeavable;
protected AsmWritableBoundClass(String name, String id, IBytecodeProvider bytecodeProvider, ClassLoader loader) {
super(name, id, bytecodeProvider, loader);
@@ -392,25 +393,22 @@ class AsmWritableBoundClass extends AsmBoundClass {
int methodModifiers = Opcodes.ACC_PUBLIC;
if (isInterface())
methodModifiers |= Opcodes.ACC_ABSTRACT;
-
- String superClassName = getSuperClassName();
- String internalSuperClassName = getInternalSuperClassName();
- boolean superIsWeavable = weavingContext.isWeavable(superClassName);
- if (!isInterface() && !superIsWeavable)
+ if (!isInterface() && !isSuperWeavable())
addField(ConstantMembers.roleSet, Opcodes.ACC_PUBLIC);
+ String internalWeavableSuperClassName = getInternalWeavableSuperClassName();
- addEmptyMethod(ConstantMembers.callOrig, methodModifiers, null, null, internalSuperClassName);
- addEmptyMethod(ConstantMembers.callAllBindingsClient, methodModifiers, null, null, internalSuperClassName);
+ addEmptyMethod(ConstantMembers.callOrig, methodModifiers, null, null, internalWeavableSuperClassName);
+ addEmptyMethod(ConstantMembers.callAllBindingsClient, methodModifiers, null, null, internalWeavableSuperClassName);
// the methods callOrigStatic and accessStatic have to already exist to call it in a concrete team
if (!isInterface()) {
addEmptyMethod(getCallOrigStatic(), Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, null, null, null);
addEmptyMethod(ConstantMembers.accessStatic, Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, null, null, null);
}
- addEmptyMethod(ConstantMembers.access, methodModifiers, null, null, internalSuperClassName);
- addEmptyMethod(ConstantMembers.addOrRemoveRole, methodModifiers, null, null, internalSuperClassName);
+ addEmptyMethod(ConstantMembers.access, methodModifiers, null, null, internalWeavableSuperClassName);
+ addEmptyMethod(ConstantMembers.addOrRemoveRole, methodModifiers, null, null, internalWeavableSuperClassName);
if (!isInterface())
multiAdapter.addVisitor(new AddAfterClassLoadingHook(this.writer, this));
@@ -454,7 +452,7 @@ class AsmWritableBoundClass extends AsmBoundClass {
@Override
protected void prepareForFirstTransformation() {
if (!isTransformed && !isInterface()) {
- nodes.add(new CreateSwitchAdapter(ConstantMembers.callOrig, getInternalSuperClassName()));
+ nodes.add(new CreateSwitchAdapter(ConstantMembers.callOrig, getInternalWeavableSuperClassName()));
nodes.add(new CreateSwitchForCallAllBindingsNode());
nodes.add(new CreateAddRemoveRoleMethod());
isTransformed = true;
@@ -480,9 +478,9 @@ class AsmWritableBoundClass extends AsmBoundClass {
@Override
protected void prepareForFirstMemberAccess() {
if (!isTransformedForMemberAccess && !isInterface()) {
- String internalSuperClassName = this.weavingContext.isWeavable(getSuperClassName()) ? getInternalSuperClassName() : null;
- nodes.add(new CreateSwitchForAccessAdapter(ConstantMembers.access, internalSuperClassName, this));
- nodes.add(new CreateSwitchForAccessAdapter(ConstantMembers.accessStatic, internalSuperClassName, this));
+ String internalWeavableSuperClassName = getInternalWeavableSuperClassName();
+ nodes.add(new CreateSwitchForAccessAdapter(ConstantMembers.access, internalWeavableSuperClassName, this));
+ nodes.add(new CreateSwitchForAccessAdapter(ConstantMembers.accessStatic, internalWeavableSuperClassName, this));
isTransformedForMemberAccess = true;
}
@@ -495,4 +493,10 @@ class AsmWritableBoundClass extends AsmBoundClass {
public boolean isFirstTransformation() {
return isFirstTransformation;
}
+
+ protected boolean isSuperWeavable() {
+ if (this.superIsWeavable == null)
+ this.superIsWeavable = weavingContext.isWeavable(getSuperClassName());
+ return this.superIsWeavable;
+ }
}

Back to the top