Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2010-07-08 20:15:36 +0000
committerStephan Herrmann2010-07-08 20:15:36 +0000
commitad374a29b3c3aef284edff7c9eb014ecea155cbb (patch)
tree9df0255bfb08bc16bb2c4d622f798cfb89bb61d3 /othersrc
parent32a19a64c608aa081dab82894dc2ae5069a488ab (diff)
downloadorg.eclipse.objectteams-ad374a29b3c3aef284edff7c9eb014ecea155cbb.tar.gz
org.eclipse.objectteams-ad374a29b3c3aef284edff7c9eb014ecea155cbb.tar.xz
org.eclipse.objectteams-ad374a29b3c3aef284edff7c9eb014ecea155cbb.zip
Cleanup for Bug 318781 - [compiler] [otre] remove "BaseClassTags" bytecode attribute
Diffstat (limited to 'othersrc')
-rw-r--r--othersrc/OTRE/src/org/eclipse/objectteams/otre/BaseTagInsertion.java205
-rw-r--r--othersrc/OTRE/src/org/eclipse/objectteams/otre/ObjectTeamsTransformation.java27
-rw-r--r--othersrc/OTRE/src/org/eclipse/objectteams/otre/jplis/ObjectTeamsTransformer.java17
-rw-r--r--othersrc/OTRE/src/org/eclipse/objectteams/otre/util/CallinBindingManager.java84
4 files changed, 4 insertions, 329 deletions
diff --git a/othersrc/OTRE/src/org/eclipse/objectteams/otre/BaseTagInsertion.java b/othersrc/OTRE/src/org/eclipse/objectteams/otre/BaseTagInsertion.java
deleted file mode 100644
index 5f0b4dd95..000000000
--- a/othersrc/OTRE/src/org/eclipse/objectteams/otre/BaseTagInsertion.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/**********************************************************************
- * This file is part of the "Object Teams Runtime Environment"
- *
- * Copyright 2002-2009 Berlin Institute of Technology, Germany.
- *
- * 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: BaseTagInsertion.java 23408 2010-02-03 18:07:35Z stephan $
- *
- * Please visit http://www.objectteams.org for updates and contact.
- *
- * Contributors:
- * Berlin Institute of Technology - Initial API and implementation
- **********************************************************************/
-package org.eclipse.objectteams.otre;
-
-import org.apache.bcel.generic.*;
-import org.apache.bcel.*;
-
-
-import java.util.*;
-
-import org.eclipse.objectteams.otre.util.*;
-
-/**
- * This transformer inserts tag fields for all (topmost) bound base classes.
- * Tag fields look like this:
- * <pre>
- * public short <i>TeamName</i>_OT$Tag;
- * </pre>
- * where <i>TeamName</i> is any team which has a callin binding for this base class.
- * It also inserts initialization of this tag into every constructor.
- *
- * @version $Id: BaseTagInsertion.java 23408 2010-02-03 18:07:35Z stephan $
- * @author Christine Hundt
- * @author Stephan Herrmann
- */
-public class BaseTagInsertion
-{
- private static boolean logging = false;
- final static String tagSuffix = "_OT$Tag";
-
- static String getTagFieldName (String teamName) {
- return teamName.replace('.', '$') + tagSuffix;
- }
-
- static {
- if (System.getProperty("ot.log") != null)
- logging = true;
- }
-
- public static class SharedState extends ObjectTeamsTransformation.SharedState {
- // Record base tags of interfaces here (String->HashMap).
- // Need to be considered in all implementing classes.
- // baseName -> HashMap (teamName -> tag (Integer)):
- private HashMap<String, HashMap<String, Integer>> baseTagsOfInterfaces = new HashMap<String, HashMap<String, Integer>>();
- }
-
- SharedState state;
-
- public BaseTagInsertion(SharedState state) {
- this.state = state;
- }
-
- /**
- * @param ce
- * @param cg
- */
- public void doTransformInterface(ClassEnhancer ce, ClassGen cg) {
-
- String class_name = cg.getClassName();
- ConstantPoolGen cpg = cg.getConstantPool();
-/*
- if (interfaceTransformedClasses.contains(class_name))
- continue; // already transformed!
-*/
-
- HashMap<String, Integer> baseTags = getAllBaseTags(cg);
-
- if (baseTags == null) return; // not a bound base
-
- if (cg.isInterface())
- state.baseTagsOfInterfaces.put(class_name, baseTags);
-
- state.interfaceTransformedClasses.add(class_name);
- if (logging)
- printLogMessage("Found bound base: " + class_name);
-
- Iterator<String> teams = baseTags.keySet().iterator();
- while (teams.hasNext()) {
- String teamName = teams.next();
-
- String fieldName = getTagFieldName(teamName);//team + tagSuffix;
-
- if (cg.containsMethod("get"+fieldName, "()S") == null)
- {
- if(logging)
- printLogMessage("create base tag access get" + fieldName);
- Integer tag = baseTags.get(teamName);
- MethodGen mg = genBaseTagGetter(cpg, class_name, fieldName, tag.intValue(), cg.isInterface());
- ce.addMethod(mg.getMethod(), cg);
- }
- }
- // addedBaseTags.addAll(baseTags);
- }
-
- /**
- * Collect base tags from this class and its super interfaces.
- * @param cg
- * @return
- */
- private HashMap<String, Integer> getAllBaseTags(ClassGen cg) {
- // accumulate here base tags from bound super interfaces and this class:
- HashMap<String, Integer> baseTags = null;
-
- // TODO (SH): consider all transformed super interfaces.
- String superIfc = getTransformedSuperIfc(cg);
- if (superIfc != null)
- baseTags = state.baseTagsOfInterfaces.get(superIfc);
-
- String class_name = cg.getClassName();
- HashMap<String, Integer> classBaseTags = CallinBindingManager.getBaseTags(class_name);
- if (CallinBindingManager.isRole(class_name)) {
- // search for base tags inherited from the implicit super (role) class:
- HashMap<String, Integer> inheritedBaseTags = CallinBindingManager.getInheritedBaseTags(class_name);
- classBaseTags.putAll(inheritedBaseTags);
- // search for base tags of the implementing role class:
- String implementingRoleName = ObjectTeamsTransformation.genImplementingRoleName(class_name);
- HashMap<String, Integer> implementingRolebaseTags = CallinBindingManager.getBaseTags(implementingRoleName);
- classBaseTags.putAll(implementingRolebaseTags);
- // TODO: check, if the we also need the implicitly inherited tags of the implementing role class!
- }
-
- if (baseTags == null)
- baseTags = classBaseTags;
- else
- baseTags.putAll(classBaseTags);
-
- return baseTags;
- }
-
- /**
- * Search the interfaces implemented by the class `cg' for an interface
- * that is a bound base.
- * TODO (SH): should return all such interfaces!
- * @param cg
- * @return
- */
- private String getTransformedSuperIfc(ClassGen cg) {
- String[] ifcs = cg.getInterfaceNames();
- for (int i=0; i<ifcs.length; i++){
- if (state.interfaceTransformedClasses.contains(ifcs[i]))
- return ifcs[i];
- }
- return null;
- }
-
- /**
- * Generate a getter method for the base tag field.
- * @param cpg
- * @param class_name this (base-) class shall carry the new method
- * @param fieldName name of the tag field.
- * @param abstractFlg should the method be generated as abstract (ie., without a body)?
- * @return
- */
- static MethodGen genBaseTagGetter(
- ConstantPoolGen cpg, String class_name,
- String fieldName, int tagValue, boolean abstractFlg)
- {
- int accessFlags = Constants.ACC_PUBLIC;
- if (abstractFlg)
- accessFlags |= Constants.ACC_ABSTRACT;
-
- InstructionList il = new InstructionList();
- MethodGen mg = new MethodGen(
- accessFlags,
- Type.SHORT, Type.NO_ARGS, new String[]{},
- "get"+fieldName, class_name,
- il, cpg);
- if (!abstractFlg) {
- // gen: "return <constant tagValue>"
- il.append(new PUSH(cpg, tagValue));
- il.append(InstructionFactory.createReturn(Type.INT));
- }
- mg.setMaxStack();
- mg.setMaxLocals();
- return mg;
- }
-
- /**
- * Insert tag initializations into each constructor.
- */
- public void doTransformCode(ClassGen cg) {
- // FIXME(SH): do not declare as CodeTransformer.
- }
-
- /**
- * @param message
- */
- private static void printLogMessage(String message) {
- System.out.println(message);
- }
-}
diff --git a/othersrc/OTRE/src/org/eclipse/objectteams/otre/ObjectTeamsTransformation.java b/othersrc/OTRE/src/org/eclipse/objectteams/otre/ObjectTeamsTransformation.java
index 844d930cd..b569a96fb 100644
--- a/othersrc/OTRE/src/org/eclipse/objectteams/otre/ObjectTeamsTransformation.java
+++ b/othersrc/OTRE/src/org/eclipse/objectteams/otre/ObjectTeamsTransformation.java
@@ -1068,7 +1068,6 @@ public abstract class ObjectTeamsTransformation
if (flag == 1) {
CallinBindingManager.addBaseClassForModifierChange(names[0]);
} else {
- CallinBindingManager.addExtraReferencedBase(class_name, names[0]);
// [OT/Equinox]: store adapted bases:
adaptedBases.add(names[0]);
}
@@ -1085,31 +1084,6 @@ public abstract class ObjectTeamsTransformation
classesToLoad.add(referenced_team);
}
- } else if (attrName.equals("BaseClassTags")) {
- numberOfEntries = 2;
- String baseClass = "";
- int tag = 0;
- HashMap<String, Integer> tagMap = new HashMap<String, Integer>();
-
- int i = 2;
- int n = 2 * count * numberOfEntries; //count << 2;
- while (i <= n) {
- for (int j = 0; j < numberOfEntries; j++) {
- int nextIndex = combineTwoBytes(indizes, i);
- if (j == 0) {
- ConstantUtf8 cons = (ConstantUtf8) cpg
- .getConstant(nextIndex);
- baseClass = cons.getBytes();
- } else if (j == 1) {
- tag = nextIndex;
- }
- i += 2;
- }
- tagMap.put(baseClass, Integer.valueOf(tag));
- if(logging) printLogMessage("**** found Base tag: " + class_name + "."
- + baseClass + "->" + tag);
- }
- CallinBindingManager.addBaseTags(class_name, tagMap);
} else if (attrName.equals("PlayedBy")) {
names = new String[1];
scanStrings(names, indizes, 0, cpg);
@@ -1304,7 +1278,6 @@ public abstract class ObjectTeamsTransformation
attrName.equals("WrappedRoleSignature") ||
attrName.equals("WrappedBaseSignature") ||
attrName.equals("ReferencedTeams") ||
- attrName.equals("BaseClassTags") ||
attrName.equals("PlayedBy") ||
attrName.equals("Modifiers") ||
attrName.equals("OTCompilerVersion") ||
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 9db6ab0b0..d0f5d05ac 100644
--- a/othersrc/OTRE/src/org/eclipse/objectteams/otre/jplis/ObjectTeamsTransformer.java
+++ b/othersrc/OTRE/src/org/eclipse/objectteams/otre/jplis/ObjectTeamsTransformer.java
@@ -27,9 +27,12 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.bcel.classfile.ClassParser;
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.generic.ClassGen;
+import org.apache.bcel.util.ClassLoaderRepository;
import org.eclipse.objectteams.otre.BaseCallRedirection;
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.OTConstants;
@@ -42,11 +45,6 @@ import org.eclipse.objectteams.otre.ThreadActivation;
import org.eclipse.objectteams.otre.util.AttributeReadingGuard;
import org.eclipse.objectteams.otre.util.CallinBindingManager;
-import org.apache.bcel.classfile.ClassParser;
-import org.apache.bcel.classfile.JavaClass;
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.util.ClassLoaderRepository;
-
/**
* Main entry into the OTRE when using JPLIS
@@ -60,7 +58,6 @@ public class ObjectTeamsTransformer implements ClassFileTransformer {
static Class<?>[] transformerClasses = new Class<?>[] {
BaseCallRedirection.class,
BaseMethodTransformation.class,
- BaseTagInsertion.class,
Decapsulation.class,
LiftingParticipantTransformation.class,
StaticSliceBaseTransformation.class,
@@ -75,7 +72,6 @@ public class ObjectTeamsTransformer implements ClassFileTransformer {
static class StateGroup {
ObjectTeamsTransformation.SharedState bcrState = new ObjectTeamsTransformation.SharedState();
ObjectTeamsTransformation.SharedState bmtState = new ObjectTeamsTransformation.SharedState();
- BaseTagInsertion.SharedState btiState = new BaseTagInsertion.SharedState();
Decapsulation.SharedState decState = new Decapsulation.SharedState();
ObjectTeamsTransformation.SharedState lptState = new ObjectTeamsTransformation.SharedState();
ObjectTeamsTransformation.SharedState ssbtState = new ObjectTeamsTransformation.SharedState();
@@ -133,8 +129,6 @@ public class ObjectTeamsTransformer implements ClassFileTransformer {
= new BaseCallRedirection( loader, states.bcrState);
BaseMethodTransformation baseMethodTransformation
= new BaseMethodTransformation( loader, states.bmtState);
- BaseTagInsertion baseTagInsertion
- = new BaseTagInsertion( states.btiState);
Decapsulation decapsulation
= new Decapsulation( loader, states.decState);
LiftingParticipantTransformation liftingParticipantTransformation
@@ -181,7 +175,6 @@ public class ObjectTeamsTransformer implements ClassFileTransformer {
System.err.println("Error transforming class: "+cg.getClassName());
t.printStackTrace();
}
- baseTagInsertion.doTransformInterface(jpe, cg);
staticSliceBaseTransformation.doTransformInterface(jpe, cg);
teamInterfaceImplementation.doTransformInterface(jpe, cg);
@@ -189,7 +182,6 @@ public class ObjectTeamsTransformer implements ClassFileTransformer {
// baseCallRedirection.doTransformInterface(jpe, cg);
// decapsulation.doTransformInterface(jpe, cg);
// baseMethodTransformation.doTransformInterface(jpe, cg);
-// baseTagInsertion.doTransformInterface(jpe, cg);
// staticSliceBaseTransformation.doTransformInterface(jpe, cg);
// teamInterfaceImplementation.doTransformInterface(jpe, cg);
threadActivation.doTransformInterface(jpe, cg);
@@ -197,7 +189,6 @@ public class ObjectTeamsTransformer implements ClassFileTransformer {
// baseCallRedirection.doTransformCode(cg); // empty method
baseMethodTransformation.doTransformCode(cg);
- baseTagInsertion.doTransformCode(cg);
liftingParticipantTransformation.doTransformCode(cg);
staticSliceBaseTransformation.doTransformCode(cg);
teamInterfaceImplementation.doTransformCode(cg);
diff --git a/othersrc/OTRE/src/org/eclipse/objectteams/otre/util/CallinBindingManager.java b/othersrc/OTRE/src/org/eclipse/objectteams/otre/util/CallinBindingManager.java
index 8339cd787..2ef71a958 100644
--- a/othersrc/OTRE/src/org/eclipse/objectteams/otre/util/CallinBindingManager.java
+++ b/othersrc/OTRE/src/org/eclipse/objectteams/otre/util/CallinBindingManager.java
@@ -53,10 +53,6 @@ public class CallinBindingManager {
// maps a team to its contained roles: teamClassName -> List[RoleClassName]
private static ListValueHashMap<String> rolesPerTeam = new ListValueHashMap<String>();
- // store sets of bases indexed by a team name,
- // where the team adapts (decapsulates) the given bases without a direct playedBy relation
- private static HashMap<String, HashSet<String>> extraReferencedBases = new HashMap<String, HashSet<String>>();
-
/**
* Add super-link of the BoundRole object for the RoleBaseBinding of 'className' to 'superClassName'.
* @param className the name of the class for which to add the super-link
@@ -199,26 +195,6 @@ public class CallinBindingManager {
return allRoles.contains(roleName);
}
- public static void addExtraReferencedBase(String teamName, String baseName) {
- HashSet<String> bases = extraReferencedBases.get(teamName);
- if (bases == null) {
- bases = new HashSet<String>();
- extraReferencedBases.put(teamName, bases);
- }
- bases.add(baseName);
- }
-
- /**
- * Get all bases adapted by a team without a direct playedBy relation.
- * @param teamName
- * @return non-null Set (may be empty).
- */
- public static Set<String> getExtraReferencedBases(String teamName) {
- Set<String> bases = extraReferencedBases.get(teamName);
- if (bases != null)
- return bases;
- return new HashSet<String>();
- }
/**
* Declare binding of a pair of methods.
@@ -909,66 +885,6 @@ public class CallinBindingManager {
}
return result;
}
-
-
- // -----------------------------------------------
- // tags for teams per base class:
- // -----------------------------------------------
- // baseName -> HashMap (teamName -> tag (Integer))
- private static HashMap<String, HashMap<String, Integer>> baseTags = new HashMap<String, HashMap<String, Integer>>();
-
- /**
- * @param teamName
- * @param baseToTag
- */
- public static void addBaseTags (String teamName, HashMap<String, Integer> baseToTag) {
- Iterator<Entry<String, Integer>> iter = baseToTag.entrySet().iterator();
- while (iter.hasNext()) {
- Entry<String,Integer> entry = iter.next();
- String baseName = entry.getKey();
- Integer tag = entry.getValue();
- HashMap<String, Integer> thisBaseTags = baseTags.get(baseName);
- if (thisBaseTags == null) {
- thisBaseTags = new HashMap<String, Integer>();
- baseTags.put(baseName, thisBaseTags);
- }
- thisBaseTags.put(teamName, tag);
- }
- }
-
- /**
- * Get all tags of teams which have callins for a given base class.
- * @param baseClassName base class name.
- * @return HashMap: team name -> tag (Integer)
- */
- public static HashMap<String, Integer> getBaseTags (String baseClassName) {
- HashMap<String, Integer> baseClassTags = baseTags.get(baseClassName);
- if (baseClassTags == null)
- return new HashMap<String, Integer>();
- return baseTags.get(baseClassName);
- }
-
- /**
- * Get all tags of teams which have callins for implicit super types
- * of the given base class.
- * Note: this is only possible if the base class is a role at the same time!
- * @param baseClassName base class name.
- * @return HashMap: team name -> tag (Integer)
- */
- public static HashMap<String, Integer> getInheritedBaseTags(String baseClassName) {
- HashMap<String, Integer> result = new HashMap<String, Integer>();
- // clone for re-entrance:
- Iterator<String> it = getBaseBindingsKeyIterator();
- while (it.hasNext()) {
- String have = it.next();
- // look for true superClass (not same):
- if (have.equals(baseClassName))
- continue;
- if (isImplicitSubtype(baseClassName, have))
- result.putAll(getBaseTags(have));
- }
- return result;
- }
// -----------------------------------------------
// callout bindings that require adjustment:

Back to the top