diff options
Diffstat (limited to 'othersrc/OTRE')
10 files changed, 30 insertions, 141 deletions
diff --git a/othersrc/OTRE/src/org/eclipse/objectteams/otre/BaseCallRedirection.java b/othersrc/OTRE/src/org/eclipse/objectteams/otre/BaseCallRedirection.java index 709592c4a..65574f39b 100644 --- a/othersrc/OTRE/src/org/eclipse/objectteams/otre/BaseCallRedirection.java +++ b/othersrc/OTRE/src/org/eclipse/objectteams/otre/BaseCallRedirection.java @@ -57,7 +57,6 @@ public class BaseCallRedirection extends ObjectTeamsTransformation { public InstructionHandle snd() {return _ih2; } } - public BaseCallRedirection(SharedState state) { this(null, state); } public BaseCallRedirection(ClassLoader loader, SharedState state) { super(loader, state); } diff --git a/othersrc/OTRE/src/org/eclipse/objectteams/otre/BaseMethodTransformation.java b/othersrc/OTRE/src/org/eclipse/objectteams/otre/BaseMethodTransformation.java index 89a485450..a5984463b 100644 --- a/othersrc/OTRE/src/org/eclipse/objectteams/otre/BaseMethodTransformation.java +++ b/othersrc/OTRE/src/org/eclipse/objectteams/otre/BaseMethodTransformation.java @@ -132,15 +132,12 @@ public class BaseMethodTransformation private final static int NORESULT = -1; - // FIXME(SH): once we remove JMangler support, these maps can be reduced to their RHS because then we'll consistently have one transformer per class: - private HashMap /* class_name -> HashSet(method_name) */<String, HashSet<String>> transformableMethods = new HashMap<String, HashSet<String>>(); - private HashMap /* class_name -> HashSet(method_name) */<String, HashSet<String>> overridableMethods = new HashMap<String, HashSet<String>>(); + // methods awaiting statements as an initial wrapper: + private HashSet<String/*methodName*/> pendingInitialWrappers; + // methods awaiting a super call to an existing initial wrapper: + private HashSet<String/*methodName*/> pendingSuperDelegationWrappers; public boolean useReflection = false; - - public BaseMethodTransformation(SharedState state) { - this(null, state); - } public BaseMethodTransformation(ClassLoader loader, SharedState state) { super(loader, state); @@ -175,11 +172,9 @@ public class BaseMethodTransformation String method_signature = m.getSignature(); if (state.interfaceTransformedClasses.contains(class_name)) { - HashSet<String> transformable = transformableMethods.get(class_name); - HashSet<String> overridable = overridableMethods.get(class_name); - if (transformable.contains(method_name + '.' + method_signature)) + if (pendingInitialWrappers.contains(method_name + '.' + method_signature)) cg.replaceMethod(m, m = generateInitialWrapper(m, class_name, cg.getMajor(), cpg)); - else if (overridable.contains(method_name + '.' + method_signature)) + else if (pendingSuperDelegationWrappers.contains(method_name + '.' + method_signature)) cg.replaceMethod(m, m = generateSuperCall(m, cg, cpg)); Method replacement = checkReplaceWickedSuper(class_name, m, cpg); @@ -252,16 +247,11 @@ public class BaseMethodTransformation } } - HashSet<String> transformedMethods = transformableMethods.get(class_name); - if (transformedMethods == null) { - transformedMethods = new HashSet<String>(); - transformableMethods.put(class_name, transformedMethods); - } - HashSet<String> renamedMethods = overridableMethods.get(class_name); - if (renamedMethods == null) { - renamedMethods = new HashSet<String>(); - overridableMethods.put(class_name, renamedMethods); - } + if (pendingInitialWrappers == null) + pendingInitialWrappers = new HashSet<String>(); + if (pendingSuperDelegationWrappers == null) + pendingSuperDelegationWrappers = new HashSet<String>(); + checkReadClassAttributes(ce, cg, class_name, cpg); @@ -352,8 +342,9 @@ public class BaseMethodTransformation int firstLine = STEP_OVER_LINENUMBER; String original_signature = method_signature; /*if (bindingsForMethod != null || containsSign(inheritedSigns, m)*/ /*|| containsSign(interfaceInheritedSigns, m)*/ //) { - MethodBinding match= matchingBinding(inheritedBindings, m, false); - if (bindingsForMethod != null || (match!= null && !m.isStatic() && !m.isPrivate())) { + MethodBinding inheritedBinding = matchingBinding(inheritedBindings, m, false); + String method_key = method_name+'.'+method_signature; + if (bindingsForMethod != null || (inheritedBinding != null && !m.isStatic() && !m.isPrivate())) { mg = newMethodGen(m, class_name, cpg); Method orig_method; @@ -377,10 +368,12 @@ public class BaseMethodTransformation if(logging) printLogMessage("Method " + method_name + " was backuped as " //$NON-NLS-1$ //$NON-NLS-2$ + name_orig + '.'); - if (match == null || method_signature.equals(match.getBaseMethodSignature())) - renamedMethods.add(method_name+'.'+method_signature); - else // override with covariant return: at the VM-level this is a *new* method. - transformedMethods.add(method_name+'.'+method_signature); + if (inheritedBinding != null) { + if (method_signature.equals(inheritedBinding.getBaseMethodSignature())) + pendingSuperDelegationWrappers.add(method_key); + else // override with covariant return: at the VM-level this is a *new* method, need a new initial wrapper + pendingInitialWrappers.add(method_key); + } } /*if (bindingsForMethod != null || (containsSign(inheritedSigns,m) && m.isStatic())*/ /*|| containsSign(interfaceInheritedSigns, m)*/ //) { @@ -395,7 +388,8 @@ public class BaseMethodTransformation if (cg.containsMethod(chain.getName(), chain.getSignature()) == null) ce.addMethod(chain, cg); - transformedMethods.add(method_name + '.' + method_signature); + pendingInitialWrappers.add(method_key); + pendingSuperDelegationWrappers.remove(method_key); // might have prematurely added this above } if (mg == null) if (logging) printLogMessage("No method binding (direct or inherited) found for " //$NON-NLS-1$ diff --git a/othersrc/OTRE/src/org/eclipse/objectteams/otre/Decapsulation.java b/othersrc/OTRE/src/org/eclipse/objectteams/otre/Decapsulation.java index e34f221ce..c7a5c1980 100644 --- a/othersrc/OTRE/src/org/eclipse/objectteams/otre/Decapsulation.java +++ b/othersrc/OTRE/src/org/eclipse/objectteams/otre/Decapsulation.java @@ -16,7 +16,6 @@ **********************************************************************/ package org.eclipse.objectteams.otre; -import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -38,8 +37,7 @@ import org.apache.bcel.generic.Type; /** * For each base method that is bound by callout and has * insufficient visibility, the visibility is set to public. - * If the corresponding JMangler-patch is installed, check - * whether the affected base class resides in a sealed package. + * Check whether the affected base class resides in a sealed package. * In that case dissallow decapsulation by throwing an IllegalAccessError. * * @version $Id: Decapsulation.java 23408 2010-02-03 18:07:35Z stephan $ @@ -53,19 +51,14 @@ public class Decapsulation // HashSet modifiedPackages = new HashSet(); public static class SharedState extends ObjectTeamsTransformation.SharedState { - private HashMap /* class_name -> HashSet(callout accessed fields) */<String, HashSet<String>> generatedFieldCalloutAccessors - = new HashMap<String, HashSet<String>>(); - private HashMap /* class_name -> HashSet(super-accessed methods (sign))*/<String, HashSet<String>> generatedSuperAccessors - = new HashMap<String, HashSet<String>>(); + private HashSet<String/*callout accessed fields*/> generatedFieldCalloutAccessors = new HashSet<String>(); + private HashSet<String/*super-accessed methods (sign)*/> generatedSuperAccessors = new HashSet<String>(); } @Override SharedState state() { return (SharedState)this.state; } - public Decapsulation(SharedState state) { - this(null, state); - } public Decapsulation(ClassLoader loader, SharedState state) { super(loader, state); // FIXME(SH): can we ever release this transformer and its state? @@ -220,7 +213,7 @@ public class Decapsulation private void generateFieldAccessForCallout(ClassEnhancer ce, ClassGen cg, String class_name, ConstantPoolGen cpg) { InstructionFactory factory = null; - HashSet<String> addedAccessMethods = state().generatedFieldCalloutAccessors.get(class_name); + HashSet<String> addedAccessMethods = state().generatedFieldCalloutAccessors; List<FieldDescriptor> getter = CallinBindingManager.getCalloutGetFields(class_name); if (getter != null) { @@ -237,7 +230,6 @@ public class Decapsulation continue; // this getter has already been created ce.addMethod(generateGetter(cpg, class_name, fd, factory), cg); addedAccessMethods.add(key); - state().generatedFieldCalloutAccessors.put(class_name, addedAccessMethods); } } @@ -257,7 +249,6 @@ public class Decapsulation continue; // this setter has already been created ce.addMethod(generateSetter(cpg, class_name, fd, factory), cg); addedAccessMethods.add(key); - state().generatedFieldCalloutAccessors.put(class_name, addedAccessMethods); } } } @@ -359,7 +350,7 @@ public class Decapsulation private void generateSuperAccessors(ClassEnhancer ce, ClassGen cg, String class_name, ConstantPoolGen cpg) { InstructionFactory factory = null; - HashSet<String> addedAccessMethods = state().generatedSuperAccessors.get(class_name); + HashSet<String> addedAccessMethods = state().generatedSuperAccessors; List<SuperMethodDescriptor> methods = CallinBindingManager.getSuperAccesses(class_name); if (methods != null) { @@ -374,7 +365,6 @@ public class Decapsulation continue; // this accessor has already been created ce.addMethod(generateSuperAccessor(cpg, class_name, superMethod, factory), cg); addedAccessMethods.add(key); - state().generatedSuperAccessors.put(class_name, addedAccessMethods); } } } diff --git a/othersrc/OTRE/src/org/eclipse/objectteams/otre/LiftingParticipantTransformation.java b/othersrc/OTRE/src/org/eclipse/objectteams/otre/LiftingParticipantTransformation.java index 9c10f8194..1adcaeffa 100644 --- a/othersrc/OTRE/src/org/eclipse/objectteams/otre/LiftingParticipantTransformation.java +++ b/othersrc/OTRE/src/org/eclipse/objectteams/otre/LiftingParticipantTransformation.java @@ -66,8 +66,6 @@ public class LiftingParticipantTransformation extends ObjectTeamsTransformation private static final String CREATE_ROLE_METHOD = "createRole"; private static final String LIFTING_PARTICIPANT_FIELD = "_OT$liftingParticipant"; - public LiftingParticipantTransformation(SharedState state) { this(null, state); } - public LiftingParticipantTransformation(ClassLoader loader, SharedState state) { super(loader, state); } public void doTransformCode(ClassGen cg) diff --git a/othersrc/OTRE/src/org/eclipse/objectteams/otre/LowerableTransformation.java b/othersrc/OTRE/src/org/eclipse/objectteams/otre/LowerableTransformation.java deleted file mode 100644 index 52c672693..000000000 --- a/othersrc/OTRE/src/org/eclipse/objectteams/otre/LowerableTransformation.java +++ /dev/null @@ -1,72 +0,0 @@ -/********************************************************************** - * This file is part of the "Object Teams Runtime Environment" - * - * Copyright 2009 Stephan Herrmann - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * $Id: LowerableTransformation.java 23408 2010-02-03 18:07:35Z stephan $ - * - * Please visit http://www.objectteams.org for updates and contact. - * - * Contributors: - * Stephan Herrmann - Initial API and implementation - **********************************************************************/ -package org.eclipse.objectteams.otre; - -import java.util.HashSet; -import java.util.Set; - -import org.apache.bcel.Constants; -import org.apache.bcel.generic.ClassGen; -import org.apache.bcel.generic.MethodGen; -import org.apache.bcel.generic.Type; - -/** - * This transformer helps legacy class files pre 1.3.2 to cope with changes re ILowerable.lower(). - * - * @author stephan - * @since 1.3.2 - */ -public class LowerableTransformation extends ObjectTeamsTransformation { - - // static because checking is performed without instance context (from scanClassOTAttribrutes) - // using ClassGen rather than names should, however, avoid conflicts between different class loaders etc. - static Set<ClassGen> transformationRequests = new HashSet<ClassGen>(); - - public LowerableTransformation(SharedState state) { this(null, state); } - - public LowerableTransformation(ClassLoader loader, SharedState state) { - super(loader, state); - } - - public void doTransformInterface(ClassEnhancer ce, ClassGen cg) { - synchronized (transformationRequests) { - if (!transformationRequests.remove(cg)) - return; - } - // yes, a change was requested, add method "public abstract Object lower();" - MethodGen lower = new MethodGen(Constants.ACC_PUBLIC|Constants.ACC_ABSTRACT, object, new Type[0], new String[0], "lower", cg.getClassName(), null, cg.getConstantPool()); - ce.addMethod(lower.getMethod(), cg); - } - - /** After reading the compiler version of a class file, check if this class is affected by the change. */ - public static void checkRequiresAdaptation(int major, int minor, int revision, ClassGen cg) { - // only 1.3.1 and below: - if (major > 1) return; - if (major == 1 && minor > 3) return; - if (major == 1 && minor == 3 && revision > 1) return; - // only interfaces ... - if (!cg.isInterface()) return; - // ... implementing ILowerabel: - for (String superInterface : cg.getInterfaceNames()) { - if ("org.objectteams.Team$ILowerable".equals(superInterface)) - synchronized(transformationRequests) { - transformationRequests.add(cg); - return; - } - } - } -} diff --git a/othersrc/OTRE/src/org/eclipse/objectteams/otre/ObjectTeamsTransformation.java b/othersrc/OTRE/src/org/eclipse/objectteams/otre/ObjectTeamsTransformation.java index 121f57c19..7f664c5f9 100644 --- a/othersrc/OTRE/src/org/eclipse/objectteams/otre/ObjectTeamsTransformation.java +++ b/othersrc/OTRE/src/org/eclipse/objectteams/otre/ObjectTeamsTransformation.java @@ -49,7 +49,7 @@ import org.apache.bcel.generic.*; /** * Superclass for all transformations in this package. - * This class and its subclasses depends on neither JMangler nor JPLIS. + * This class and its subclasses does not directly depend on JPLIS. * * Contains common fields and methods. * @@ -109,8 +109,6 @@ public abstract class ObjectTeamsTransformation /** Which class loader are we working for? */ protected ClassLoader loader; - - public ObjectTeamsTransformation(SharedState state) { this(null, state); } public ObjectTeamsTransformation(ClassLoader loader, SharedState state) { this.loader = loader; @@ -1131,7 +1129,6 @@ public abstract class ObjectTeamsTransformation if(logging) printLogMessage("**** class file was produced by compiler version " + major + "." + minor + "." + revision + " ****"); IS_COMPILER_GREATER_123 = false; // reset, may be updated below - LowerableTransformation.checkRequiresAdaptation(major, minor, revision, cg); // 1.4 stream: if (major == 1 && minor == 4) { if (revision < OT14_REVISION) { diff --git a/othersrc/OTRE/src/org/eclipse/objectteams/otre/StaticSliceBaseTransformation.java b/othersrc/OTRE/src/org/eclipse/objectteams/otre/StaticSliceBaseTransformation.java index 6ba98aebd..5e5844f04 100644 --- a/othersrc/OTRE/src/org/eclipse/objectteams/otre/StaticSliceBaseTransformation.java +++ b/othersrc/OTRE/src/org/eclipse/objectteams/otre/StaticSliceBaseTransformation.java @@ -47,7 +47,6 @@ public class StaticSliceBaseTransformation static final String _OT_ACTIVE_TEAMS= "_OT$activeTeams"; //$NON-NLS-1$ static final String _OT_ACTIVE_TEAM_IDS= "_OT$activeTeamIDs"; //$NON-NLS-1$ - public StaticSliceBaseTransformation(SharedState state) { this(null, state); } public StaticSliceBaseTransformation(ClassLoader loader, SharedState state) { super(loader, state); } public void doTransformCode(ClassGen cg) { diff --git a/othersrc/OTRE/src/org/eclipse/objectteams/otre/SubBoundBaseMethodRedefinition.java b/othersrc/OTRE/src/org/eclipse/objectteams/otre/SubBoundBaseMethodRedefinition.java index e107fda04..1a0db28b4 100644 --- a/othersrc/OTRE/src/org/eclipse/objectteams/otre/SubBoundBaseMethodRedefinition.java +++ b/othersrc/OTRE/src/org/eclipse/objectteams/otre/SubBoundBaseMethodRedefinition.java @@ -38,7 +38,6 @@ import org.eclipse.objectteams.otre.util.*; public class SubBoundBaseMethodRedefinition extends ObjectTeamsTransformation { - public SubBoundBaseMethodRedefinition(SharedState state) { this(null, state); } public SubBoundBaseMethodRedefinition(ClassLoader loader, SharedState state) { super(loader, state); } /** diff --git a/othersrc/OTRE/src/org/eclipse/objectteams/otre/TeamInterfaceImplementation.java b/othersrc/OTRE/src/org/eclipse/objectteams/otre/TeamInterfaceImplementation.java index de2c85020..8ce3abac3 100644 --- a/othersrc/OTRE/src/org/eclipse/objectteams/otre/TeamInterfaceImplementation.java +++ b/othersrc/OTRE/src/org/eclipse/objectteams/otre/TeamInterfaceImplementation.java @@ -44,16 +44,9 @@ import org.eclipse.objectteams.otre.util.*; public class TeamInterfaceImplementation extends ObjectTeamsTransformation { - private boolean isJPLIS; - - public TeamInterfaceImplementation(boolean isJPLIS, SharedState state) { - this(isJPLIS, null, state); - } - - public TeamInterfaceImplementation(boolean isJPLIS, ClassLoader loader, SharedState state) { + public TeamInterfaceImplementation(ClassLoader loader, SharedState state) { super(loader, state); - this.isJPLIS = isJPLIS; } /** @@ -416,8 +409,6 @@ public class TeamInterfaceImplementation private String getErrorMessage(String teamName, String baseName, String action) { String errorMessage = action+" of team '" + teamName + "' failed! Callins of this team have NOT been WOVEN into base class '" + baseName + "'!\n" + "This is probably caused by a loading order problem."; - if (!isJPLIS) - errorMessage += "\nIf "+baseName+" is loaded from the bootstrap classpath launching the program in JPLIS mode may perhaps avoid this problem."; return errorMessage; } diff --git a/othersrc/OTRE/src/org/eclipse/objectteams/otre/jplis/ObjectTeamsTransformer.java b/othersrc/OTRE/src/org/eclipse/objectteams/otre/jplis/ObjectTeamsTransformer.java index d89a3d960..745174715 100644 --- a/othersrc/OTRE/src/org/eclipse/objectteams/otre/jplis/ObjectTeamsTransformer.java +++ b/othersrc/OTRE/src/org/eclipse/objectteams/otre/jplis/ObjectTeamsTransformer.java @@ -32,7 +32,6 @@ import org.eclipse.objectteams.otre.BaseMethodTransformation; import org.eclipse.objectteams.otre.BaseTagInsertion; import org.eclipse.objectteams.otre.Decapsulation; import org.eclipse.objectteams.otre.LiftingParticipantTransformation; -import org.eclipse.objectteams.otre.LowerableTransformation; import org.eclipse.objectteams.otre.OTConstants; import org.eclipse.objectteams.otre.ObjectTeamsTransformation; import org.eclipse.objectteams.otre.RepositoryAccess; @@ -64,7 +63,6 @@ public class ObjectTeamsTransformer implements ClassFileTransformer { BaseTagInsertion.class, Decapsulation.class, LiftingParticipantTransformation.class, - LowerableTransformation.class, StaticSliceBaseTransformation.class, SubBoundBaseMethodRedefinition.class, TeamInterfaceImplementation.class, @@ -80,7 +78,6 @@ public class ObjectTeamsTransformer implements ClassFileTransformer { BaseTagInsertion.SharedState btiState = new BaseTagInsertion.SharedState(); Decapsulation.SharedState decState = new Decapsulation.SharedState(); ObjectTeamsTransformation.SharedState lptState = new ObjectTeamsTransformation.SharedState(); - ObjectTeamsTransformation.SharedState lowState = new ObjectTeamsTransformation.SharedState(); ObjectTeamsTransformation.SharedState ssbtState = new ObjectTeamsTransformation.SharedState(); ObjectTeamsTransformation.SharedState sbbmrState = new ObjectTeamsTransformation.SharedState(); ObjectTeamsTransformation.SharedState tiiState = new ObjectTeamsTransformation.SharedState(); @@ -141,14 +138,12 @@ public class ObjectTeamsTransformer implements ClassFileTransformer { = new Decapsulation( loader, states.decState); LiftingParticipantTransformation liftingParticipantTransformation = new LiftingParticipantTransformation( loader, states.lptState); - LowerableTransformation lowerableTransformation - = new LowerableTransformation( loader, states.lowState); StaticSliceBaseTransformation staticSliceBaseTransformation = new StaticSliceBaseTransformation( loader, states.ssbtState); SubBoundBaseMethodRedefinition subBoundBaseMethodRedefinition = new SubBoundBaseMethodRedefinition( loader, states.sbbmrState); TeamInterfaceImplementation teamInterfaceImplementation - = new TeamInterfaceImplementation(true, loader, states.tiiState); + = new TeamInterfaceImplementation( loader, states.tiiState); ThreadActivation threadActivation = new ThreadActivation(); @@ -186,7 +181,6 @@ public class ObjectTeamsTransformer implements ClassFileTransformer { t.printStackTrace(); } baseTagInsertion.doTransformInterface(jpe, cg); - lowerableTransformation.doTransformInterface(jpe, cg); staticSliceBaseTransformation.doTransformInterface(jpe, cg); teamInterfaceImplementation.doTransformInterface(jpe, cg); |