Bug 397182 - Prepare OTDT for new (dynamic) weaver
- fix creating of inner base via decapsulated base ctor call
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/BaseAllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/BaseAllocationExpression.java
index 0817561..da46649 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/BaseAllocationExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/BaseAllocationExpression.java
@@ -254,19 +254,21 @@
}
public static Expression convertToDynAccess(BlockScope scope, AllocationExpression expression, int accessId) {
- AstGenerator gen = new AstGenerator(expression);
- Expression receiver;
- char[] selector;
- int modifiers = ClassFileConstants.AccPublic;
TypeBinding baseclass = expression.resolvedType;
+ AstGenerator gen = new AstGenerator(expression);
+ Expression receiver = gen.typeReference(baseclass);
+ char[] selector = CalloutImplementorDyn.OT_ACCESS_STATIC;
+ int modifiers = ClassFileConstants.AccPublic|ClassFileConstants.AccStatic;
+ Expression[] arguments = expression.arguments;
if (expression instanceof QualifiedAllocationExpression) {
- receiver = ((QualifiedAllocationExpression) expression).enclosingInstance;
- selector = CalloutImplementorDyn.OT_ACCESS;
- // FIXME: here we should call a non-static outer._OT$access() which must invoke this.new Inner().
- } else {
- receiver = gen.typeReference(baseclass);
- selector = CalloutImplementorDyn.OT_ACCESS_STATIC;
- modifiers |= ClassFileConstants.AccStatic;
+ Expression enclosingInstance = ((QualifiedAllocationExpression) expression).enclosingInstance;
+ if (arguments == null) {
+ arguments = new Expression[] { enclosingInstance };
+ } else {
+ int len = arguments.length;
+ System.arraycopy(arguments, 0, arguments = new Expression[len+1], 1, len);
+ arguments[0] = enclosingInstance;
+ }
}
MessageSend allocSend = new MessageSend() {
@Override
@@ -282,16 +284,15 @@
gen.setPositions(allocSend);
allocSend.receiver = receiver;
allocSend.selector = selector;
- allocSend.arguments = expression.arguments;
allocSend.constant = Constant.NotAConstant;
allocSend.actualReceiverType = baseclass;
allocSend.accessId = accessId;
- allocSend.arguments = createResolvedAccessArguments(gen, accessId, expression.arguments, scope);
+ allocSend.arguments = createResolvedAccessArguments(gen, accessId, arguments, scope);
allocSend.binding = new MethodBinding(modifiers, new TypeBinding[] {
TypeBinding.INT,
TypeBinding.INT,
scope.createArrayType(scope.getJavaLangObject(), 1),
- scope.getOrgObjectteamsITeam()
+ scope.getOrgObjectteamsITeam()
},
Binding.NO_EXCEPTIONS,
(ReferenceBinding) baseclass);
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateMethodAccessAdapter.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateMethodAccessAdapter.java
index 4035760..af24ec8 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateMethodAccessAdapter.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateMethodAccessAdapter.java
@@ -75,13 +75,10 @@
Type[] args = Type.getArgumentTypes(methodNode.desc);
if (args.length > 0) {
- instructions.add(new IntInsnNode(Opcodes.ALOAD, firstArgIndex + 2));
for (int i = 0; i < args.length; i++) {
- if (i < args.length - 1) {
- instructions.add(new InsnNode(Opcodes.DUP));
- }
+ instructions.add(new IntInsnNode(Opcodes.ALOAD, firstArgIndex + 2));
instructions.add(createLoadIntConstant(i));
instructions.add(new InsnNode(Opcodes.AALOAD));
Type arg = args[i];
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/roleplaying/ExplicitRoleCreation.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/roleplaying/ExplicitRoleCreation.java
index 3830065..7893d72 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/roleplaying/ExplicitRoleCreation.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/roleplaying/ExplicitRoleCreation.java
@@ -3800,7 +3800,7 @@
" protected final Team2335crori2_1 lower = new Team2335crori2_1();\n" +
" protected class R playedBy Inner<@lower> {\n" +
" protected R(Team2335crori2_1 outer) {\n" +
- " outer.base(\"OK\");\n" +
+ " outer.base(\"OK\");\n" + // TODO: is outer. acceptable, shouldn't it always be lower.base()??
" }\n" +
" String getVal() -> get String val;\n" +
" protected void print() {\n" +