Bug 433137 [otdre] otequinox should support OTDRE via some switch
diff --git a/plugins/org.eclipse.objectteams.otequinox/Status.txt b/plugins/org.eclipse.objectteams.otequinox/Status.txt
index 6107204..d11f990 100644
--- a/plugins/org.eclipse.objectteams.otequinox/Status.txt
+++ b/plugins/org.eclipse.objectteams.otequinox/Status.txt
@@ -1,14 +1,8 @@
See https://bugs.eclipse.org/bugs/show_bug.cgi?id=406518
-(0) Register our WeavingHook as early as possible during start-up.
-Done, but need re-thinking. TJ said on equinox-dev: use start level 1
NOTYET:
-------
-(5) Add dependencies so that each bound base bundle can see:
- - the OT runtime (package org.objectteams)
- - the aspect bundle(s) into which the woven code may call
-Pending: dynamically export the aspect package if not statically declared
(8) Subclasses of Thread (and ideally: implementors of Runnable, the latter
has not yet been realized) need to be woven to insert a trigger into OT's
diff --git a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/AspectBinding.java b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/AspectBinding.java
index 3415076..5f67f2e 100644
--- a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/AspectBinding.java
+++ b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/AspectBinding.java
@@ -33,7 +33,6 @@
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.objectteams.internal.osgi.weaving.Util.ProfileKind;
import org.eclipse.objectteams.otequinox.ActivationKind;
-import org.eclipse.objectteams.otre.jplis.ObjectTeamsTransformer;
import org.objectteams.Team;
import org.osgi.framework.Bundle;
import org.osgi.framework.hooks.weaving.WovenClass;
@@ -224,7 +223,7 @@
/** Create an initial (unconnected) resolved team binding. */
public TeamBinding createResolvedTeam(int count, String teamName, @Nullable String activationSpecifier, @Nullable String superTeamName) {
- ActivationKind kind = ActivationKind.NONE;
+ @NonNull ActivationKind kind = ActivationKind.NONE;
try {
if (activationSpecifier != null)
kind = ActivationKind.valueOf(activationSpecifier);
@@ -288,7 +287,7 @@
* Read OT attributes of all teams in this aspectBinding
* and collect affected base classes into the teamBindings.
*/
- public synchronized void scanTeamClasses(Bundle bundle) {
+ public synchronized void scanTeamClasses(Bundle bundle, DelegatingTransformer transformer) {
long time = 0;
if (Util.PROFILE) time= System.nanoTime();
ClassScanner scanner = new ClassScanner();
@@ -296,14 +295,14 @@
if (team.hasScannedBases) { // not a surprise for members of equivalentSet or classes already processed by weave()
if (!team.hasScannedRoles) { // weave() only scans bases, not roles!
team.hasScannedRoles = true;
- scanner.readMemberTypeAttributes(bundle, team.teamName, new ObjectTeamsTransformer());
+ scanner.readMemberTypeAttributes(bundle, team.teamName, transformer);
}
continue;
}
team.hasScannedBases = true;
team.hasScannedRoles = true;
try {
- String teamName = scanner.readOTAttributes(bundle, team.teamName);
+ String teamName = scanner.readOTAttributes(bundle, team.teamName, transformer);
Collection<String> baseClassNames = scanner.getCollectedBaseClassNames();
if (team.baseClassNames.isEmpty()) {
for (TeamBinding equivalent : team.equivalenceSet)
diff --git a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/BaseBundleLoadTrigger.java b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/BaseBundleLoadTrigger.java
index c867f0a..c97841f 100644
--- a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/BaseBundleLoadTrigger.java
+++ b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/BaseBundleLoadTrigger.java
@@ -1,7 +1,7 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
*
- * Copyright 2013 GK Software AG
+ * Copyright 2013, 2014 GK Software AG
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -73,6 +73,8 @@
log(IStatus.INFO, "Adding OTRE import to "+baseBundleName);
List<String> imports = baseClass.getDynamicImports();
imports.add("org.objectteams");
+ if (hook.useDynamicWeaver)
+ imports.add("org.eclipse.objectteams.otredyn.runtime"); // for access to TeamManager
}
}
@@ -100,13 +102,15 @@
}
// (2) scan all teams in affecting aspect bindings:
if (!aspectBinding.hasScannedTeams)
- aspectBinding.scanTeamClasses(aspectBundle);
+ aspectBinding.scanTeamClasses(aspectBundle, DelegatingTransformer.newTransformer(hook.useDynamicWeaver));
+ // TODO: record adapted base classes?
// (3) add dependencies to the base bundle:
- aspectBinding.addImports(baseClass);
+ if (!hook.useDynamicWeaver) // OTDRE access aspects by generic interface in o.o.Team
+ aspectBinding.addImports(baseClass);
// (4) try optional steps:
- TeamLoader loading = new TeamLoader(deferredTeamClasses, beingDefined);
+ TeamLoader loading = new TeamLoader(deferredTeamClasses, beingDefined, hook.useDynamicWeaver);
loading.loadTeamsForBase(aspectBundle, aspectBinding, baseClass);
}
}
diff --git a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/ClassScanner.java b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/ClassScanner.java
index 5d22727..4a7fd39 100644
--- a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/ClassScanner.java
+++ b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/ClassScanner.java
@@ -1,7 +1,7 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
*
- * Copyright 2008, 2013 Technical University Berlin, Germany and others
+ * Copyright 2008, 2014 Technical University Berlin, Germany and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -30,7 +30,6 @@
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.objectteams.otre.jplis.ObjectTeamsTransformer;
import org.eclipse.objectteams.otre.util.CallinBindingManager;
import org.osgi.framework.Bundle;
@@ -69,18 +68,17 @@
* @throws IOException
* @throws ClassNotFoundException the team or role class was not found
*/
- public String readOTAttributes(Bundle bundle, String className)
+ public String readOTAttributes(Bundle bundle, String className, DelegatingTransformer transformer)
throws ClassFormatError, IOException, ClassNotFoundException
{
- Object loader = REPOSITORY_USE_RESOURCE_LOADER ? bundle : null;
+ Bundle loader = REPOSITORY_USE_RESOURCE_LOADER ? bundle : null;
Pair<URL,String> result = TeamLoader.findTeamClassResource(className, bundle);
if (result == null)
throw new ClassNotFoundException(className);
URL classFile = result.first;
className = result.second;
- ObjectTeamsTransformer transformer = new ObjectTeamsTransformer();
try (InputStream inputStream = classFile.openStream()) {
- transformer.readOTAttributes(inputStream, classFile.getFile(), loader);
+ transformer.readOTAttributes(className, inputStream, classFile.getFile(), loader);
}
Collection<String> currentBaseNames = transformer.fetchAdaptedBases(); // destructive read
if (currentBaseNames != null) {
@@ -132,7 +130,7 @@
*/
void readMemberTypeAttributes(Bundle bundle,
String className,
- ObjectTeamsTransformer transformer)
+ DelegatingTransformer transformer)
{
List<String> roles = CallinBindingManager.getRolePerTeam(className);
if (roles != null) {
@@ -140,7 +138,7 @@
log(IStatus.OK, "scanning role "+roleName);
try {
this.roleClassNames.add(roleName);
- readOTAttributes(bundle, roleName);
+ readOTAttributes(bundle, roleName, transformer);
} catch (Throwable t) {
log(t, "Failed to read OT-Attributes of role "+roleName);
}
diff --git a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/DelegatingTransformer.java b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/DelegatingTransformer.java
new file mode 100644
index 0000000..abd710c
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/DelegatingTransformer.java
@@ -0,0 +1,88 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2014 GK Software AG
+ *
+ * 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
+ *
+ * Please visit http://www.objectteams.org for updates and contact.
+ *
+ * Contributors:
+ * Stephan Herrmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.internal.osgi.weaving;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.instrument.IllegalClassFormatException;
+import java.security.ProtectionDomain;
+import java.util.Collection;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.osgi.framework.Bundle;
+
+/**
+ * Generalization over the transformers of OTRE and OTDRE.
+ */
+public abstract class DelegatingTransformer {
+
+ /** Factory method for a fresh transformer. */
+ static @NonNull DelegatingTransformer newTransformer(boolean useDynamicWeaver) {
+ if (useDynamicWeaver)
+ return new OTDRETransformer();
+ else
+ return new OTRETransformer();
+ }
+
+ private static class OTRETransformer extends DelegatingTransformer {
+ org.eclipse.objectteams.otre.jplis.ObjectTeamsTransformer transformer = new org.eclipse.objectteams.otre.jplis.ObjectTeamsTransformer();
+ @Override
+ public void readOTAttributes(String className, InputStream inputStream, String fileName, Bundle bundle) throws ClassFormatError, IOException {
+ this.transformer.readOTAttributes(inputStream, fileName, bundle);
+ }
+ public Collection<String> fetchAdaptedBases() {
+ return this.transformer.fetchAdaptedBases();
+ }
+ public byte[] transform(Bundle bundle, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] bytes)
+ throws IllegalClassFormatException
+ {
+ return this.transformer.transform(bundle, className, classBeingRedefined, protectionDomain, bytes);
+ }
+ }
+
+ private static class OTDRETransformer extends DelegatingTransformer {
+ org.eclipse.objectteams.otredyn.transformer.jplis.ObjectTeamsTransformer transformer =
+ new org.eclipse.objectteams.otredyn.transformer.jplis.ObjectTeamsTransformer();
+ @Override
+ public void readOTAttributes(String className, InputStream inputStream, String fileName, Bundle bundle) throws ClassFormatError, IOException {
+ // TODO provide classID
+ this.transformer.readOTAttributes(className, className.replace('.', '/'), inputStream, getBundleLoader(bundle));
+ }
+ public Collection<String> fetchAdaptedBases() {
+ return transformer.fetchAdaptedBases();
+ }
+ public byte[] transform(final Bundle bundle, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] bytes) {
+ // TODO provide classID
+ return transformer.transform(getBundleLoader(bundle), className, className.replace('.', '/'), classBeingRedefined, bytes);
+ }
+ }
+
+ static ClassLoader getBundleLoader(final Bundle bundle) {
+ return new ClassLoader() {
+ @Override
+ public Class<?> loadClass(String name) throws ClassNotFoundException {
+ return bundle.loadClass(name);
+ }
+ };
+ }
+
+ public abstract void readOTAttributes(String className, InputStream inputStream, String fileName, Bundle bundle) throws ClassFormatError, IOException;
+
+ public abstract byte[] transform(Bundle bundle, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] bytes)
+ throws IllegalClassFormatException;
+
+ public abstract Collection<String> fetchAdaptedBases();
+}
diff --git a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/OTWeavingHook.java b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/OTWeavingHook.java
index e305789..882189b 100644
--- a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/OTWeavingHook.java
+++ b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/OTWeavingHook.java
@@ -1,7 +1,7 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
*
- * Copyright 2013 GK Software AG
+ * Copyright 2013, 2014 GK Software AG
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -36,7 +36,6 @@
import org.eclipse.objectteams.internal.osgi.weaving.Util.ProfileKind;
import org.eclipse.objectteams.otequinox.Constants;
import org.eclipse.objectteams.otequinox.TransformerPlugin;
-import org.eclipse.objectteams.otre.jplis.ObjectTeamsTransformer;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -66,6 +65,9 @@
*/
public class OTWeavingHook implements WeavingHook, WovenClassListener {
+ // TODO: this master-switch, which selects the weaver, should probably be replaced by s.t. else?
+ boolean useDynamicWeaver = "dynamic".equals(System.getProperty("ot.weaving"));
+
enum WeavingReason { None, Aspect, Base }
/** Interface to data about aspectBinding extensions. */
@@ -151,7 +153,7 @@
// do whatever is needed *before* loading this class:
triggerBaseTripWires(bundleName, wovenClass);
- ObjectTeamsTransformer transformer = new ObjectTeamsTransformer();
+ DelegatingTransformer transformer = DelegatingTransformer.newTransformer(useDynamicWeaver);
Class<?> classBeingRedefined = null; // TODO prepare for otre-dyn
ProtectionDomain protectionDomain = wovenClass.getProtectionDomain();
byte[] bytes = wovenClass.getBytes();
@@ -161,7 +163,7 @@
if (Util.PROFILE) time= System.nanoTime();
byte[] newBytes = transformer.transform(bundleWiring.getBundle(),
className, classBeingRedefined, protectionDomain, bytes);
- if (newBytes != bytes && !Arrays.equals(newBytes, bytes)) {
+ if (newBytes != null && newBytes != bytes && !Arrays.equals(newBytes, bytes)) {
if (Util.PROFILE) Util.profile(time, ProfileKind.Transformation, className);
log(IStatus.INFO, "Transformation performed on "+className);
wovenClass.setBytes(newBytes);
@@ -189,7 +191,7 @@
return WeavingReason.None;
}
- private void recordBaseClasses(ObjectTeamsTransformer transformer, @NonNull String aspectBundle, String className) {
+ private void recordBaseClasses(DelegatingTransformer transformer, @NonNull String aspectBundle, String className) {
Collection<String> adaptedBases = transformer.fetchAdaptedBases();
if (adaptedBases == null || adaptedBases.isEmpty()) return;
List<AspectBinding> aspectBindings = aspectBindingRegistry.getAspectBindings(aspectBundle);
@@ -242,7 +244,7 @@
String teamName = record.team.teamName;
log(IStatus.INFO, "Consider for instantiation/activation: team "+teamName);
try {
- TeamLoader loader = new TeamLoader(deferredTeams, beingDefined);
+ TeamLoader loader = new TeamLoader(deferredTeams, beingDefined, this.useDynamicWeaver);
// Instantiate (we only get here if activationKind != NONE)
loader.instantiateAndActivate(record.aspectBinding, record.team, record.activationKind); // may re-insert to deferredTeams
} catch (Exception e) {
diff --git a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/TeamLoader.java b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/TeamLoader.java
index 9e5e72d..8805c8d 100644
--- a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/TeamLoader.java
+++ b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/TeamLoader.java
@@ -1,7 +1,7 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
*
- * Copyright 2013 GK Software AG
+ * Copyright 2013, 2014 GK Software AG
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -31,6 +31,7 @@
import org.eclipse.objectteams.internal.osgi.weaving.Util.ProfileKind;
import org.eclipse.objectteams.otequinox.ActivationKind;
import org.eclipse.objectteams.otequinox.TransformerPlugin;
+import org.eclipse.objectteams.otredyn.runtime.TeamManager;
import org.objectteams.Team;
import org.osgi.framework.Bundle;
import org.osgi.framework.hooks.weaving.WovenClass;
@@ -57,9 +58,12 @@
private Set<String> beingDefined;
- public TeamLoader(List<WaitingTeamRecord> deferredTeams, Set<String> beingDefined) {
+ boolean useDynamicWeaving;
+
+ public TeamLoader(List<WaitingTeamRecord> deferredTeams, Set<String> beingDefined, boolean useDynamicWeaving) {
this.deferredTeams = deferredTeams;
this.beingDefined = beingDefined;
+ this.useDynamicWeaving = useDynamicWeaving;
}
/**
@@ -154,8 +158,11 @@
String teamName = team.teamName;
// don't try to instantiate before all base classes successfully loaded.
synchronized(aspectBinding) {
- if (!isReadyToLoad(aspectBinding, team, teamName, activationKind))
+ if (!isReadyToLoad(aspectBinding, team, teamName, activationKind)) {
+ if (this.useDynamicWeaving)
+ TeamManager.prepareTeamActivation(team.teamClass);
return;
+ }
for (TeamBinding equivalent : team.equivalenceSet)
equivalent.isActivated = true;
}
diff --git a/plugins/org.eclipse.objectteams.otredyn/META-INF/MANIFEST.MF b/plugins/org.eclipse.objectteams.otredyn/META-INF/MANIFEST.MF
index 4fcd432..6f240a3 100644
--- a/plugins/org.eclipse.objectteams.otredyn/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.objectteams.otredyn/META-INF/MANIFEST.MF
@@ -5,8 +5,7 @@
Bundle-Version: 0.8.0.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
-Export-Package: org.objectteams,
- org.eclipse.objectteams.otredyn.bytecode,
+Export-Package: org.eclipse.objectteams.otredyn.bytecode,
org.eclipse.objectteams.otredyn.bytecode.asm,
org.eclipse.objectteams.otredyn.runtime,
org.eclipse.objectteams.otredyn.transformer,
@@ -15,6 +14,7 @@
org.eclipse.objectteams.otredyn.util
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ClassPath: .
-Require-Bundle: org.objectweb.asm;bundle-version="5.0.1",
+Require-Bundle: org.eclipse.objectteams.runtime;bundle-version="[2.3.0,3.0.0)",
+ 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/AbstractBoundClass.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/AbstractBoundClass.java
index 3c38a7f..9938322 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
@@ -374,7 +374,7 @@
/**
* This method parses the bytecode, if that has not already been done
*/
- protected abstract void parseBytecode();
+ public abstract void parseBytecode();
/**
* Returns the internal name of the super class of this class
@@ -1012,6 +1012,8 @@
public void dump(byte[] classfileBuffer, String postfix) {}
+ public Collection<String> getBoundBaseClasses() { return null; }
+
public abstract int compare(String callinLabel1, String callinLabel2);
public void addWiringTask(ISubclassWiringTask wiringTask) {
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 3bebdf6..de20cb6 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
@@ -16,6 +16,9 @@
**********************************************************************/
package org.eclipse.objectteams.otredyn.bytecode.asm;
+import java.util.Collection;
+import java.util.Set;
+
import org.eclipse.objectteams.otredyn.bytecode.AbstractBoundClass;
import org.eclipse.objectteams.otredyn.bytecode.AbstractTeam;
import org.eclipse.objectteams.otredyn.bytecode.IBytecodeProvider;
@@ -44,6 +47,12 @@
*/
public String[] precedences;
+ /**
+ * Set of base classes to which the current class or one of its roles as playedBy bindings.
+ * Qualified class names are '.' separated.
+ */
+ public Set<String> boundBaseClasses;
+
protected AsmBoundClass(String name, String id, IBytecodeProvider bytecodeProvider, ClassLoader loader) {
super(name, id, loader);
this.bytecodeProvider = bytecodeProvider;
@@ -54,7 +63,7 @@
* of {@link AbstractBoundClass} to set the information
*/
@Override
- protected synchronized void parseBytecode() {
+ public synchronized void parseBytecode() {
if (parsed) {
// Already parsed, nothing to do
return;
@@ -78,6 +87,11 @@
bytecode = null;
}
+ @Override
+ public Collection<String> getBoundBaseClasses() {
+ return this.boundBaseClasses;
+ }
+
/**
* Returns the bytecode of this class and cache it temporary.
* This method is only needed, if getBytecode of the {@link IBytecodeProvider}
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 15ac4c6..0d58abf 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
@@ -1,7 +1,7 @@
/**********************************************************************
* This file is part of "Object Teams Dynamic Runtime Environment"
*
- * Copyright 2009, 2012 Oliver Frank and others.
+ * Copyright 2009, 2014 Oliver Frank and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -16,8 +16,9 @@
**********************************************************************/
package org.eclipse.objectteams.otredyn.bytecode.asm;
+import java.util.HashSet;
+
import org.eclipse.objectteams.otredyn.bytecode.Binding;
-import org.eclipse.objectteams.otredyn.bytecode.Types;
import org.eclipse.objectteams.otredyn.bytecode.asm.Attributes.CallinBindingsAttribute;
import org.eclipse.objectteams.otredyn.bytecode.asm.Attributes.OTClassFlagsAttribute;
import org.eclipse.objectteams.otredyn.bytecode.asm.Attributes.CallinBindingsAttribute.MultiBinding;
@@ -89,6 +90,8 @@
*/
@Override
public void visitAttribute(Attribute attribute) {
+ if (clazz.boundBaseClasses == null)
+ clazz.boundBaseClasses = new HashSet<String>();
if (attribute.type.equals(Attributes.ATTRIBUTE_OT_DYN_CALLIN_BINDINGS)) {
CallinBindingsAttribute attr = (CallinBindingsAttribute) attribute;
MultiBinding[] multiBindings = attr.getBindings();
@@ -96,6 +99,7 @@
String roleClassName = multiBindings[i].getRoleClassName();
String callinLabel = multiBindings[i].getCallinLabel();
String baseClassName = multiBindings[i].getBaseClassName();
+ clazz.boundBaseClasses.add(baseClassName.replace('/', '.'));
String[] baseMethodNames = multiBindings[i].getBaseMethodNames();
String[] baseMethodSignatures = multiBindings[i].getBaseMethodSignatures();
String[] declaringBaseClassNames = multiBindings[i].getDeclaringBaseClassName();
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/runtime/TeamManager.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/runtime/TeamManager.java
index 8cdfb2d..122fb08 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/runtime/TeamManager.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/runtime/TeamManager.java
@@ -23,6 +23,8 @@
import org.eclipse.objectteams.otredyn.bytecode.AbstractBoundClass;
import org.objectteams.ITeam;
+import org.objectteams.ITeamManager;
+import org.objectteams.Team;
/**
* This class administrates the the active teams and their
@@ -34,12 +36,8 @@
* @author Oliver Frank
*
*/
-public class TeamManager {
-
- public static enum TeamStateChange {
- REGISTER,
- UNREGISTER
- }
+public class TeamManager implements ITeamManager {
+
// void handleTeamStateChange(ITeam t, TeamStateChange stateChange) ;
private static List<List<ITeam>> _teams = new ArrayList<List<ITeam>>();
private static List<List<Integer>> _callinIds = new ArrayList<List<Integer>>();
@@ -53,6 +51,7 @@
public static void setup(IClassRepository repo) {
classRepository = repo;
+ Team.registerTeamManager(new TeamManager()); // install callback
}
/**
@@ -160,7 +159,7 @@
* @param t
* @param stateChange
*/
- public static void handleTeamStateChange(ITeam t, TeamManager.TeamStateChange stateChange) {
+ public void handleTeamStateChange(ITeam t, ITeamManager.TeamStateChange stateChange) {
IClassIdentifierProvider provider = ClassIdentifierProviderFactory.getClassIdentifierProvider();
Class<? extends ITeam> teamClass = t.getClass();
String teamId = provider.getClassIdentifier(teamClass);
@@ -184,12 +183,37 @@
for (Integer subJoinpoint : subJoinpoints)
changeTeamsForJoinpoint(t, binding.getPerTeamId(), subJoinpoint, stateChange);
}
- boundClass.handleAddingOfBinding(binding); // TODO(SH): more lazy
+ boundClass.handleAddingOfBinding(binding); // TODO: do we want/need to group all bindings into one action?
break;
}
-
}
}
+
+ /**
+ * When a team is about to be activated propagate its bindings to all base classes,
+ * but don't yet register any join points, we aren't activating yet.
+ */
+ public static void prepareTeamActivation(Class<? extends ITeam> teamClass) {
+ String teamName = teamClass.getName();
+ ClassLoader teamClassLoader = teamClass.getClassLoader();
+ IClassIdentifierProvider provider = ClassIdentifierProviderFactory.getClassIdentifierProvider();
+ String teamId = provider.getClassIdentifier(teamClass);
+ IBoundTeam teem = classRepository.getTeam(teamName, teamId, teamClassLoader);
+
+ for (IBinding binding : teem.getBindings()) {
+ String boundClassName = binding.getBoundClass();
+ String boundClassIdentifier = provider.getBoundClassIdentifier(teamClass, boundClassName);
+ // FIXME(SH): the following may need adaptation for OT/Equinox or other multi-classloader settings:
+ IBoundClass boundClass = classRepository.getBoundClass(boundClassName.replace('/', '.'), boundClassIdentifier, teamClass.getClassLoader());
+ // FIXME(SH): if boundClass is a role we need to find tsub roles, too!
+ switch (binding.getType()) {
+ case CALLIN_BINDING:
+ boundClass.handleAddingOfBinding(binding);
+ break;
+ }
+ }
+ }
+
public static void handleTeamLoaded(Class<? extends ITeam> teamClass) {
if (teamClass != null)
handleDecapsulation(teamClass);
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/transformer/jplis/ObjectTeamsTransformer.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/transformer/jplis/ObjectTeamsTransformer.java
index f091510..9fd100e 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/transformer/jplis/ObjectTeamsTransformer.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/transformer/jplis/ObjectTeamsTransformer.java
@@ -15,8 +15,13 @@
**********************************************************************/
package org.eclipse.objectteams.otredyn.transformer.jplis;
+import java.io.IOException;
+import java.io.InputStream;
import java.lang.instrument.ClassFileTransformer;
import java.security.ProtectionDomain;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
import org.eclipse.objectteams.otredyn.bytecode.AbstractBoundClass;
import org.eclipse.objectteams.otredyn.bytecode.ClassRepository;
@@ -26,16 +31,16 @@
* This class does all needed transformations at load time.
* @author Christine Hundt
*/
-
public class ObjectTeamsTransformer implements ClassFileTransformer {
+
+ private Set<String> boundBaseClassNames = new HashSet<String>();
+
/* (non-Javadoc)
* @see java.lang.instrument.ClassFileTransformer#transform(java.lang.ClassLoader, java.lang.String, java.lang.Class, java.security.ProtectionDomain, byte[])
*/
-
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined,
- ProtectionDomain protectionDomain, byte[] classfileBuffer) {
-
-
+ ProtectionDomain protectionDomain, byte[] classfileBuffer)
+ {
return transform(loader, className, className, classBeingRedefined, classfileBuffer);
}
@@ -66,6 +71,8 @@
t.printStackTrace();
}
+ this.boundBaseClassNames.addAll(clazz.getBoundBaseClasses());
+
return classfileBuffer;
}
@@ -105,4 +112,39 @@
}
return true;
}
+
+ /** Parse the bytecode of the given class, so we are able to answer {@link #fetchAdaptedBases()} afterwards. */
+ public void readOTAttributes(String className, String classId, InputStream inputStream, ClassLoader loader) throws ClassFormatError, IOException {
+ AbstractBoundClass clazz = ClassRepository.getInstance().getBoundClass(
+ className.replace('/','.'), classId, loader);
+ if (!clazz.isFirstTransformation()) {
+ return; // FIXME: re-loading existing class?? Investigate classloader, check classId strategy etc.pp.
+ }
+ try {
+ if (clazz.isTransformationActive()) {
+ return;
+ }
+ int available = inputStream.available();
+ byte[] bytes = new byte[available];
+ inputStream.read(bytes);
+ clazz = ClassRepository.getInstance().getBoundClass(
+ className, classId, bytes, loader);
+ if (!clazz.isInterface())
+ ClassRepository.getInstance().linkClassWithSuperclass(clazz);
+ if (!clazz.isInterface() || clazz.isRole())
+ clazz.parseBytecode();
+ } catch(Throwable t) {
+ t.printStackTrace();
+ }
+
+ this.boundBaseClassNames.addAll(clazz.getBoundBaseClasses());
+ }
+
+ /**
+ * After {@link #transform(ClassLoader, String, Class, ProtectionDomain, byte[])} or {@link #readOTAttributes(String, String, InputStream, ClassLoader)}
+ * this method will answer the qualified names (dot-separated) of all base classes adapated by the current team and its roles.
+ */
+ public Collection<String> fetchAdaptedBases() {
+ return this.boundBaseClassNames;
+ }
}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/DoublyWeakHashMap.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/DoublyWeakHashMap.java
deleted file mode 100644
index faa3da8..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/DoublyWeakHashMap.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/**********************************************************************
- * This file is part of the "Object Teams Runtime Environment"
- *
- * Copyright 2010 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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Stephan Herrmann - Initial API and implementation
- **********************************************************************/
-package org.objectteams;
-
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-import java.util.WeakHashMap;
-
-/**
- * This class defines hash maps where both key and value are weak references.
- * It is implemented by delegating to a WeakHashMap and additionally
- * wrapping the value in a WeakReference.
- *
- * @author stephan
- * @since 0.7.0
- * @param <K> type of keys: a base class
- * @param <V> type of values: a role class
- */
-public class DoublyWeakHashMap<K,V> implements Map<K,V> {
-
- private WeakHashMap<K, WeakReference<V>> map;
-
- public DoublyWeakHashMap() {
- this.map = new WeakHashMap<K, WeakReference<V>>();
- }
-
- public int size() {
- return this.map.size();
- }
-
- public boolean isEmpty() {
- return this.map.isEmpty();
- }
-
- // used from hasRole() and lifting (duplicate role check)
- public boolean containsKey(Object key) {
- return this.map.containsKey(key);
- }
-
- public boolean containsValue(Object value) {
- throw new UnsupportedFeatureException("Method containsValue is not implemented for internal class DoublyWeakHashMap.");
- }
-
- // used from getRole()
- public V get(Object key) {
- WeakReference<V> valRef = this.map.get(key);
- return valRef == null ? null : valRef.get();
- }
-
- // used from migrateToBase() and lifting constructor
- public synchronized V put(K key, V value) {
- this.map.put(key, new WeakReference<V>(value));
- return value;
- }
-
- // used from unregisterRole(), migrateToBase()
- public synchronized V remove(Object key) {
- WeakReference<V> value = this.map.remove(key);
- return (value == null) ? null : value.get();
- }
-
- public void putAll(Map<? extends K, ? extends V> t) {
- for (Entry<? extends K, ? extends V> entry : t.entrySet())
- this.map.put(entry.getKey(), new WeakReference<V>(entry.getValue()));
- }
-
- public void clear() {
- this.map.clear();
- }
-
- public Set<K> keySet() {
- return this.map.keySet();
- }
-
- // used from getAllRoles() et al.
- public synchronized Collection<V> values() {
- ArrayList<V> result = new ArrayList<V>(this.map.size());
- for (WeakReference<V> valRef : this.map.values()) {
- V value = valRef.get();
- if (value != null)
- result.add(value);
- }
- return result;
- }
-
- public Set<java.util.Map.Entry<K, V>> entrySet() {
- throw new UnsupportedFeatureException("Method entrySet is not implemented for internal class DoublyWeakHashMap.");
- }
-}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/DuplicateRoleException.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/DuplicateRoleException.java
deleted file mode 100644
index 9d5c069..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/DuplicateRoleException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**********************************************************************
- * This file is part of "Object Teams Dynamic Runtime Environment"
- *
- * Copyright 2004, 2010 Berlin Institute of Technology, Germany, and others.
- *
- * 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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Berlin Institute of Technology - Initial API and implementation
- **********************************************************************/
-package org.objectteams;
-
-/**
- * Signal a violation of OTJLD 2.4.1(c).
- * Also Team.getRole(Object) may throw a DuplicateRoleException if
- * more than one role is found for the given base object
- * (in that case those roles are found in different role-caches).
- *
- *
- * @author stephan
- */
-public class DuplicateRoleException extends RuntimeException {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * @param message
- */
- public DuplicateRoleException(String roleClassName) {
- super("Failed to create a role instance of type "+roleClassName+"\n"+
- "A role for the given base object already exists (OTJLD 2.4.1(c)).");
- }
-
- public DuplicateRoleException(String roleName1, String roleName2) {
- super("Ambiguous role instances: found a role in hierarchies "+
- roleName1+" and "+roleName2);
- }
-}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/IBaseMigratable.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/IBaseMigratable.java
deleted file mode 100644
index fa49611..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/IBaseMigratable.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**********************************************************************
- * This file is part of "Object Teams Dynamic Runtime Environment"
- *
- * Copyright 2008, 2010 Berlin Institute of Technology, Germany, and others.
- *
- * 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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Berlin Institute of Technology - Initial API and implementation
- **********************************************************************/
-package org.objectteams;
-
-/**
- * Marker interface: if a role declares to implement this interface
- * the compiler will generate the method defined herein, and prepare
- * the role so that the migration will indeed be possible.
- *
- * @author stephan
- * @since 1.2.5
- */
-public interface IBaseMigratable {
- /**
- * Migrate the current role to the otherBase.
- *
- * @param otherBase new base that this role should adapt, must
- * be of a valid base type for the current role.
- */
- <B> void migrateToBase(B otherBase);
-}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/IBoundBase.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/IBoundBase.java
deleted file mode 100644
index afc892a..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/IBoundBase.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**********************************************************************
- * This file is part of "Object Teams Dynamic Runtime Environment"
- *
- * Copyright 2007, 2012 Berlin Institute of Technology, Germany, and others.
- *
- * 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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Berlin Institute of Technology - Initial API and implementation
- * Oliver Frank - Initial API and Implementation
- **********************************************************************/
-package org.objectteams;
-
-/** Super type for all bound base classes. Purely internal class, not intended for client use. */
-public interface IBoundBase {
-
- /**
- * Call a bound base method identified by its ID.
- * @param boundMethod_id globally unique ID of a bound base method
- * @param args packed arguments (incl. boxing)
- * @return (possibly boxed) result of the bound base method.
- */
- Object _OT$callOrig(int boundMethod_id, Object[] args);
-
- /**
- * Provides access to fields and methods of a base class
- * that have package, protected or private visbility
- * @param accessId Unique identifier in the class for the field or method
- * @param opKind 0 for read access, 1 for write access. only used for fields
- * @param args arguments for a method
- * @return
- */
- Object _OT$access(int accessId, int opKind, Object[] args, Team caller);
-
- /** Method to be used by generated code, only (lifting constructor & unregisterRole()). */
- void _OT$addOrRemoveRole(Object aRole, boolean adding);
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/IConfined.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/IConfined.java
deleted file mode 100644
index ca13bbc..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/IConfined.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**********************************************************************
- * This file is part of "Object Teams Dynamic Runtime Environment"
- *
- * Copyright 2004, 2010 Berlin Institute of Technology, Germany, and others.
- *
- * 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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Berlin Institute of Technology - Initial API and implementation
- **********************************************************************/
-package org.objectteams;
-
-/**
- * Special interface that does not extend Object
- *
- * @author stephan
- */
-public interface IConfined {}
\ No newline at end of file
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/ILiftingParticipant.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/ILiftingParticipant.java
deleted file mode 100644
index 725cd19..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/ILiftingParticipant.java
+++ /dev/null
@@ -1,39 +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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Stephan Herrmann - Initial API and implementation
- **********************************************************************/
-package org.objectteams;
-
-/**
- * A lifting participant hooks into the lifting process.
- *
- * @author stephan
- * @since 1.3.1
- */
-public interface ILiftingParticipant {
- /**
- * This method is called when lifting does not find a suitable role within the
- * team's internal role cache. If this method returns a non-null value,
- * this value is considered by the runtime as being the desired role
- * (i.e., it must be castable to that role type), and no new role is created.
- * If this method returns null, lifting proceeds as normal, i.e.,
- * a fresh role is created using the default lifting constructor.
- *
- * @param teamInstance
- * @param baseInstance
- * @param roleClassName
- * @return either null or an instance of the class specified by roleClassName
- */
- Object createRole(ITeam teamInstance, Object baseInstance, String roleClassName);
-}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/ITeam.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/ITeam.java
deleted file mode 100644
index ba6083c..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/ITeam.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/**********************************************************************
- * This file is part of the "Object Teams Runtime Environment"
- *
- * Copyright 2010, 2012 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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Stephan Herrmann - Initial API and implementation
- **********************************************************************/
-package org.objectteams;
-
-/**
- * Public interface of all team classes.
- */
-public interface ITeam {
-
- /**
- * Interface for all role classes that should allow explicit lowering.
- * The interface provides a phantom method <pre><B> B lower()</pre>
- * where B is the bound base class of the implementing role class.
- * There is no need to implement the method lower, since this is done by the compiler.
- */
- public interface ILowerable {
- // internal method needed for cast and instanceof
- ITeam _OT$getTeam();
- }
-
- /**
- * This role interface has no properties not even those of java.lang.Object.
- */
- public interface IConfined extends org.objectteams.IConfined {
- // internal method needed for cast and instanceof
- ITeam _OT$getTeam();
- }
-
-
- /**
- * Activates the team and therefore all of its callin bindings.
- * This activation applies to the current thread only.
- */
- public abstract void activate();
-
- /**
- * Deactivates the team and therefore all of its callin bindings.
- * This deactivation applies to the current thread only.
- */
- public abstract void deactivate();
-
- /**
- * Activates the team and therefore all of its callin bindings for passed thread.
- * If the constant 'Team.ALL_THREADS' is passed, this activation globally applies to all threads.
- */
- public abstract void activate(Thread thread);
-
- /**
- * Deactivates the team and therefore all of its callin bindings for passed thread.
- * If the constant 'Team.ALL_THREADS' is passed, this deactivation globally applies to all threads.
- */
- public abstract void deactivate(Thread thread);
-
- /**
- * Checks, if the team instance is active for the current thread.
- * @return true, if the team is active, false else.
- */
- public abstract boolean isActive();
-
- /**
- * Checks, if the team instance is active for the 'thread'.
- * @param thread The thread for which to check activity.
- * @return true, if the team is active for 'thread', false else.
- */
- public abstract boolean isActive(Thread thread);
-
- /** NOT API */
- public void _OT$implicitlyActivate();
- /** NOT API */
- public void _OT$implicitlyDeactivate();
-
- /**
- * Does given base object have a role in this team?
- * This method will consider roles of any type.
- *
- * @param aBase any object, i.e., no checks are performed whether the base object's
- * class is bound by any role class in this team.
- * @return
- */
- public abstract boolean hasRole(Object aBase);
-
- /**
- * Does given base object have a role in this team?
- * The role must be an instance of the specified role type.
- *
- * @param aBase any object, i.e., no checks are performed whether the base object's
- * class is bound by any role class in this team.
- * @param roleType Class instance specifying the required role type.
- * TODO (SH): is it legal to pass an unbound role class?
- * @throws IllegalArgumentException if <code>roleType</code> does not represent a member type of this team.
- * @return
- */
- public abstract boolean hasRole(Object aBase, Class<?> roleType) throws IllegalArgumentException;
-
- /**
- * Retrieve a role for a given base object.
- * If more than one role exists, a DuplicateRoleException is thrown.
- *
- * @param aBase
- * @return
- */
- public abstract Object getRole(Object aBase);
-
- /**
- * Retrieve a role for a given base object.
- * The role must be an instance of the specified role type.
- *
- * @param aBase any object, i.e., no checks are performed whether the base object's
- * class is bound by any role class in this team.
- * @param roleType Class instance specifying the required role type.
- * @return
- * @throws IllegalArgumentException if <code>roleType</code> does not represent a member type of this team.
- */
- public abstract <T> T getRole(Object aBase, Class<T> roleType) throws IllegalArgumentException;
-
- /**
- * Retrieve all bound roles registered in the current team.
- *
- * This method uses internal structures of weak references.
- * For that reason it may return role instances which were about to be reclaimed
- * by the garbage collector.
- * If performance permits, it is thus advisable to always call System.gc()
- * prior to calling getAllRoles() in order to achieve deterministic results
- *
- * @return a non-null array.
- */
- public abstract Object[] getAllRoles();
-
- /**
- * Retrieve all bound roles registered in the current team that
- * are instance of roleType or a subtype thereof.
- *
- * This method uses internal structures of weak references.
- * For that reason it may return role instances which were about to be reclaimed
- * by the garbage collector.
- * If performance permits, it is thus advisable to always call System.gc()
- * prior to calling getAllRoles() in order to achieve deterministic results
- *
- * @param roleType must be a top-most bound role of this team.
- * @return a non-null array.
- * @throws IllegalArgumentException if <code>roleType</code> does not represent a member type of this team.
- */
- public abstract <T> T[] getAllRoles(Class<T> roleType) throws IllegalArgumentException;
-
- /**
- * Query whether any role instance of this team instance is currently executing a
- * method due to a callin binding.
- * @return
- */
- public abstract boolean isExecutingCallin();
-
- /**
- * Remove a role from the internal registry, which means that the role will no longer be
- * considered during lifting.
- *
- * @param aRole
- */
- public abstract void unregisterRole(Object aRole);
-
- /**
- * Remove a role from the internal registry, which means that the role will no longer be
- * considered during lifting.
- *
- * @param aRole
- * @param roleType
- * @throws IllegalArgumentException if <code>roleType</code> does not represent a member type of this team.
- */
- public abstract void unregisterRole(Object aRole, Class<?> roleType) throws IllegalArgumentException;
-
- /**
- * Not API.
- * This method saves the activation state of the team for the current thread.
- * If active, it also saves, if the activation was explicit or implicit.
- * This method has to be called by the generated code when entering a within block,
- * before the activation.
- */
- public int _OT$saveActivationState();
-
- /**
- * Not API.
- * This method restores the former saved activation state of the team for the current thread.
- * If active, it also restores, if the activation was explicit or implicit.
- * This method has to be called by the generated code when leaving a within block
- * (in the finally block).
- */
- public void _OT$restoreActivationState(int old_state);
-
- /**
- * Not API, for use by TeamThreadManager, only.
- */
- public boolean internalIsActiveSpecificallyFor(Thread t);
-
- /**
- * Not API, for use by TeamThreadManager, only.
- */
- public void deactivateForEndedThread(Thread thread);
-
- /** NOT API */
- public Object _OT$callAllBindings(IBoundBase baze, ITeam[] teams,int idx,int[] callinIds, int boundMethodId, Object[] args);
-
- /** NOT API */
- public Object _OT$callOrigStatic(int callinId, int boundMethodId, Object[] args);
-
- /** NOT API */
- public Object _OT$callNext(IBoundBase baze, ITeam[] teams, int idx, int[] callinIds, int boundMethodId, Object[] args, Object[] baseCallArgs);
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/ITeamMigratable.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/ITeamMigratable.java
deleted file mode 100644
index e14750e..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/ITeamMigratable.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**********************************************************************
- * This file is part of "Object Teams Dynamic Runtime Environment"
- *
- * Copyright 2008, 2010 Berlin Institute of Technology, Germany, and others.
- *
- * 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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Berlin Institute of Technology - Initial API and implementation
- **********************************************************************/
-package org.objectteams;
-
-/**
- * Marker interface: if a role declares to implement this interface
- * the compiler will generate the method defined herein, and prepare
- * the role so that the migration will indeed be possible.
- * Note, that a migratable role does not obey the family guarantee.
- *
- * @author stephan
- * @since 1.2.5
- */
-public interface ITeamMigratable {
- /**
- * Migrate the current role to the otherTeam.
- *
- * @param otherTeam new team that should adopt this role
- * @return the migrated (and re-typed) role (actually of type R<@otherTeam>). FIXME(SH)
- */
- <R> R migrateToTeam(final ITeam otherTeam);
-}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/IllegalRoleCreationException.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/IllegalRoleCreationException.java
deleted file mode 100644
index 0842268..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/IllegalRoleCreationException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**********************************************************************
- * This file is part of "Object Teams Dynamic Runtime Environment"
- *
- * Copyright 2007, 2010 Berlin Institute of Technology, Germany, and others.
- *
- * 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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Berlin Institute of Technology - Initial API and implementation
- **********************************************************************/
-package org.objectteams;
-
-/**
- * Exception to be thrown when a bound role is being instantiated but
- * the constructor does not assign a base object.
- *
- * @author stephan
- */
-@SuppressWarnings("serial")
-public class IllegalRoleCreationException extends RuntimeException {
- public IllegalRoleCreationException() {
- super();
- }
-
- @Override
- public String getMessage() {
- return "Cannot instantiate a bound role using a default constructor of its tsuper class";
- }
-}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/ImplicitTeamActivation.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/ImplicitTeamActivation.java
deleted file mode 100644
index 0415e4d..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/ImplicitTeamActivation.java
+++ /dev/null
@@ -1,44 +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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Stephan Herrmann - Initial API and implementation
- **********************************************************************/
-package org.objectteams;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This marker annotation enables implicit team activation for the annotated element:
- * <ul>
- * <li>If attached to a method the effect is that each call to this method implicitly
- * activates the enclosing team.</li>
- * <li>If attached to a class it has the same effect as annotating all contained methods.</li>
- * </ul>
- * See <a href="http://www.objectteams.org/def/1.3/s5.html#s5.3">OTJLD § 5.3</a>.
- * <p>
- * This annotation is only evaluated if the property <code>ot.implicit.team.activation</code>
- * is set to the string <code>ANNOTATED</code>.
- * </p>
- * @author stephan
- * @since 1.4.0
- */
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD, ElementType.TYPE})
-public @interface ImplicitTeamActivation {
- /* no members, pure marker annotation. */
-}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/Instantiation.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/Instantiation.java
deleted file mode 100644
index 4392adc..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/Instantiation.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**********************************************************************
- * This file is part of "Object Teams Development Tooling"-Software
- *
- * Copyright 2011 GK Software AG
- *
- * 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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Stephan Herrmann - Initial API and implementation
- **********************************************************************/
-package org.objectteams;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation influences the semantics of lifting in OT/J.
- * See {@link InstantiationPolicy} for possible values and their effects.
- * This annotation is valid only when applied to a role type.
- *
- * @author stephan
- */
-@Documented
-@Retention(RetentionPolicy.CLASS)
-@Target(ElementType.TYPE)
-public @interface Instantiation {
- InstantiationPolicy value();
-}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/InstantiationPolicy.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/InstantiationPolicy.java
deleted file mode 100644
index 9cc189e..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/InstantiationPolicy.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**********************************************************************
- * This file is part of "Object Teams Development Tooling"-Software
- *
- * Copyright 2011 GK Software AG
- *
- * 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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Stephan Herrmann - Initial API and implementation
- **********************************************************************/
-package org.objectteams;
-
-/**
- * Possible values for the {@link Instantiation} annotation for role types:
- * {@link #NEVER}, {@link #ONDEMAND} (default), {@link #SINGLETON} and {@link #ALWAYS}.
- *
- * @author stephan
- */
-public enum InstantiationPolicy {
- /**
- * Roles with the instantiation policy NEVER are not instantiated by lifting.
- * Such roles cannot have state.
- * The compiler still has to ensure that access to base instances still behaves
- * as if a role instance would exist.
- * Note: this is not yet supported by the OT/J compiler.
- */
- NEVER,
- /**
- * The constant ONDEMAND corresponds to the default behavior in OT/J
- * where lifting will create a role for a given base instance upon first access,
- * i.e., if no matching role is found in the team's internal cache.
- * Otherwise the existing role from the cache is re-used.
- */
- ONDEMAND,
- /**
- * For a role with instantiation policy SINGLETON at most one instance per team
- * will be created by lifting. Subsequent lifting operations will always return
- * the same role instance.
- * The compiler still has to ensure that access to base instances still behaves
- * as if a role instance would exist.
- * Note: this is not yet supported by the OT/J compiler.
- */
- SINGLETON,
- /**
- * The instantiation policy ALWAYS advises the compiler to omit generating an
- * internal cache for the given role type. Instead of first consulting the
- * cache (as it is done in the default ONDEMAND policy) each lifting operation
- * creates a new role instance.
- */
- ALWAYS;
-}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/LiftingFailedException.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/LiftingFailedException.java
deleted file mode 100644
index cc77105..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/LiftingFailedException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**********************************************************************
- * This file is part of "Object Teams Dynamic Runtime Environment"
- *
- * Copyright 2003, 2010 Berlin Institute of Technology, Germany, and others.
- *
- * 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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Berlin Institute of Technology - Initial API and implementation
- **********************************************************************/
-package org.objectteams;
-
-/**
- * This exception signals that lifting failed due to unresolved
- * binding ambiguity.
- */
-public class LiftingFailedException extends Exception {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private Object base;
- private String roleType;
-
- /**
- * @param base the object that should be lifted
- * @param roleType the name of the role type for which
- * lifting was attempted.
- */
- public LiftingFailedException(Object base, String roleType) {
- this.base = base;
- this.roleType = roleType;
- }
-
- @Override
- public String getMessage() {
- return "\nFailed to lift '" + base + "' of " + base.getClass()
- + " to type '" + roleType
- + "'\n(See OT/J definition para. 2.3.4(c)).";
- }
-}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/LiftingVetoException.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/LiftingVetoException.java
deleted file mode 100644
index 2d1315d..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/LiftingVetoException.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**********************************************************************
- * This file is part of "Object Teams Dynamic Runtime Environment"
- *
- * Copyright 2003, 2010 Berlin Institute of Technology, Germany, and others.
- *
- * 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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Berlin Institute of Technology - Initial API and implementation
- **********************************************************************/
-package org.objectteams;
-
-/**
- * This exception is used by the language implementation
- * to signal a failed lifting due to a guard predicate that evaluated to false.
- * @author Stephan Herrmann
- */
-public class LiftingVetoException extends RuntimeException {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- ITeam aTeam = null;
- Object base = null;
-
- public LiftingVetoException(ITeam aTeam, Object base) {
- this.aTeam = aTeam;
- this.base = base;
- }
-
- public LiftingVetoException() {
- super("");
- }
-
- @Override
- public String toString() {
- return "Team " + aTeam + " refuses to lift " + base
- + "\n(this exception should not be seen in applications).";
- }
-}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/NoSuchMethodError.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/NoSuchMethodError.java
deleted file mode 100644
index fbc2800..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/NoSuchMethodError.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**********************************************************************
- * This file is part of "Object Teams Dynamic Runtime Environment"
- *
- * Copyright 2011 GK Software AG.
- *
- * 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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Stephan Herrmann - Initial API and implementation
- **********************************************************************/
-package org.objectteams;
-
-/**
- * This error is thrown when some generated code falls through a switch
- * without finding a requested target method.
- *
- * @author stephan
- */
-public class NoSuchMethodError extends java.lang.NoSuchMethodError {
- private static final long serialVersionUID = 8166812526610195056L;
-
- public NoSuchMethodError(int accessId, String className, String accessReason) {
- super("Method with internal id "+accessId+" cannot be found in "+className+" for "+accessReason);
- }
-}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/ResultNotProvidedException.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/ResultNotProvidedException.java
deleted file mode 100644
index b36870d..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/ResultNotProvidedException.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**********************************************************************
- * This file is part of "Object Teams Dynamic Runtime Environment"
- *
- * Copyright 2004, 2010 Berlin Institute of Technology, Germany, and others.
- *
- * 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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Berlin Institute of Technology - Initial API and implementation
- **********************************************************************/
-package org.objectteams;
-
-/**
- * @author resix
- */
-public class ResultNotProvidedException extends RuntimeException {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private static final String _bugmsg =
- "\nNo base call executed! Result value was uninitialized!\n(see OT/J language definition para. 4.3(e)).";
-
- /**
- *
- */
- public ResultNotProvidedException() {
- super(_bugmsg);
- }
-
- /**
- * @param message
- */
- public ResultNotProvidedException(String message) {
- super(_bugmsg + "\n" + message);
- StackTraceElement[] ste = new StackTraceElement[0];
- setStackTrace(ste);
- }
-
- /**
- * @param cause
- */
- public ResultNotProvidedException(Throwable cause) {
- super(_bugmsg + cause.toString());
- }
-
- /**
- * @param message
- * @param cause
- */
- public ResultNotProvidedException(String message, Throwable cause) {
- super(_bugmsg + message/* +cause.toString() */);
- }
-}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/RoleCastException.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/RoleCastException.java
deleted file mode 100644
index da03385..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/RoleCastException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**********************************************************************
- * This file is part of "Object Teams Dynamic Runtime Environment"
- *
- * Copyright 2004, 2010 Berlin Institute of Technology, Germany, and others.
- *
- * 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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Berlin Institute of Technology - Initial API and implementation
- **********************************************************************/
-package org.objectteams;
-
-/**
- * This exception is thrown if a cast to a role class fails due to
- * different enclosing team instances.
- * @author Stephan Herrmann
- */
-public class RoleCastException extends ClassCastException {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private static final String MSG =
- "Different enclosing team instances (see OT/J language definition para. 1.2.4(b)).";
-
- /* (non-Javadoc)
- * @see java.lang.Throwable#getMessage()
- */
- @Override
- public String getMessage() {
- return MSG;
- }
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/SneakyException.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/SneakyException.java
deleted file mode 100644
index 28fad1a..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/SneakyException.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**********************************************************************
- * This file is part of the "Object Teams Runtime Environment"
- *
- * Copyright 2012 GK Software AG
- *
- * 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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Stephan Herrmann - Initial API and implementation
- **********************************************************************/
-package org.objectteams;
-
-import java.io.PrintStream;
-
-/**
- * Exception class used for tunneling checked exception through generic dispatch
- * code without matching throws declaration.
- *
- * An original exception raised in a role method is wrapped during any of
- * <code>_OT$callReplace</code>, <code>_OT$callBefore</code> and <code>_OT$callAfter</code>
- * and unwrapped in the initial wrapper of any base method.
- *
- * Note that the opposite direction needs no wrapping: exceptions raised in
- * the base method are thrown as normal, because this happens inside _OT$callOrig
- * of the base class, which is created dynamically by OTREDyn and never checked
- * by any compiler.
- */
-@SuppressWarnings("serial")
-public class SneakyException extends RuntimeException {
- private Exception cause;
-
- /** Wrap a given exception in an unchecked SneakyException. */
- public SneakyException(Exception cause) {
- this.cause = cause;
- }
-
- /** Re-throw the nested exception but hide it from the compiler. */
- public void rethrow() {
- SneakyException.<RuntimeException>sneakyThrow0(this.cause);
- }
-
- @SuppressWarnings("unchecked")
- private static <T extends Exception> void sneakyThrow0(Exception t) throws T {
- throw (T)t;
- }
-
- @Override
- public String getMessage() {
- return this.cause.getMessage();
- }
-
- @Override
- public void printStackTrace(PrintStream s) {
- this.cause.printStackTrace(s);
- }
-}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/SoftLiftingFailedException.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/SoftLiftingFailedException.java
deleted file mode 100644
index 0458cc7..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/SoftLiftingFailedException.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**********************************************************************
- * This file is part of the "Object Teams Runtime Environment"
- *
- * Copyright 2011 GK Software AG
- *
- * 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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Stephan Herrmann - Initial API and implementation
- **********************************************************************/
-package org.objectteams;
-
-/**
- * This exception signals that lifting failed due to unresolved
- * binding ambiguity. This variant is used when static analysis
- * could not find reason for such failure just in case the class
- * files have changed since.
- */
-public class SoftLiftingFailedException extends RuntimeException {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private Object base;
- private String roleType;
-
- /**
- * @param base the object that should be lifted
- * @param roleType the name of the role type for which
- * lifting was attempted.
- */
- public SoftLiftingFailedException(Object base, String roleType) {
- this.base = base;
- this.roleType = roleType;
- }
-
- @Override
- public String getMessage() {
- return "\nFailed to lift '" + base + "' of " + base.getClass()
- + " to type '" + roleType
- + "'\nPerhaps some class files have changed since the enclosing team has been compiler? (See OT/J definition para. 2.3.4(c)).";
- }
-}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/Team.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/Team.java
deleted file mode 100644
index b59aaea..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/Team.java
+++ /dev/null
@@ -1,655 +0,0 @@
-/**********************************************************************
- * This file is part of "Object Teams Dynamic Runtime Environment"
- *
- * Copyright 2002, 2012 Berlin Institute of Technology, Germany, and others.
- *
- * 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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Berlin Institute of Technology - Initial API and implementation
- * Oliver Frank - Initial API and Implementation
- **********************************************************************/
-package org.objectteams;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.WeakHashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-
-import org.eclipse.objectteams.otredyn.runtime.TeamManager;
-
-
-/**
- * This is the root class of all team definitions.
- * Any class with the <tt>team</tt> modifier implicitly
- * inherits from this class.
- *
- */
-public /* team */ class Team implements ITeam {
- // Technical note: comments starting with //$Debug are intended
- // for a standalone tool that generates an interface
- // which the debugger needs in order to know about line numbers in this class.
-
- /*
- * Synchronization: This class supports two levels of synchronization:
- * <ul>
- * <li>Fields of <code>Team</code> are synchronized
- * using <code>this</code> as the monitor.
- * <li>Those calls that (un)register a team at its base classes are synchronized
- * via <code>registrationLock</code>
- * </ul>
- * This allows releasing the lock on <code>this</code> before calling to the base class.
- * Note, that the synchronized portion of each initial-wrapper is also synchronized
- * (against <code>_OT$addTeam/_OT$removeTeam</code>) and that it calls back to
- * the registered teams (method <code>isActive()</code>).
- * Without <code>registrationLock</code> this situation could easily deadlock:
- * Thread1: <pre>t.activate() -> Base._OT$addTeam()</pre>: owns t, waits for Base.
- * Thread2: <pre>b.bm() (initial wrapper) -> t.isActive()</pre>: owns Base, waits for t.
- */
-
- /**
- * Internal field used by the runtime to install a lifting participant if one is configured.
- */
- public static ILiftingParticipant _OT$liftingParticipant = null;
-
- /**
- * Default constructor for debugging purpose.
- */
- public Team() {} //$Debug(TeamConstructor)
-
- /*
- * manual copy-inheritance of a role interface from ITeam.
- */
- public interface ILowerable extends ITeam.ILowerable {}
-
- /*
- * manual copy-inheritance of a role interface from ITeam.
- */
- public interface IConfined extends ITeam.IConfined {}
-
- /**
- * Special role type that<ul>
- * <li> does not extend java.lang.Object
- * <li> may not leak references outside the team.
- * </ul>
- */
- protected interface Confined {
- /* internal method needed for cast and instanceof
- * (this method will be generated for role classes) */
- ITeam _OT$getTeam();
- }
-
- /**
- * This class would have been generated by the OT-compiler.
- * Don't explicitly use it in client code!
- */
- protected class __OT__Confined implements Confined {
- // internal method needed for cast and instanceof
- public ITeam _OT$getTeam() {
- return Team.this; //$Debug(ConfinedGetTeam)
- }
- }
-
- /**
- * Internal function for identifying a Team.
- * Should not be called by client code.
- */
- public int _OT$getID () {return -1;}
-
- /**
- * The constant <code>ALL_THREADS</code> is used for global team (de-)activation.
- */
- public static final Thread ALL_THREADS = new Thread();
-
- private static final int _OT$UNREGISTERED = 0;
- private static final int _OT$REGISTERED = 1;
- private int _OT$registrationState = _OT$UNREGISTERED;
-
- private boolean _OT$globalActive = false;
-
- private ThreadLocal<Integer> _OT$implicitActivationsPerThread = new ThreadLocal<Integer>() {
- @Override
- protected synchronized Integer initialValue() {
- return Integer.valueOf(0);
- }
- };
-
- private boolean _OT$lazyGlobalActiveFlag = false;
-
- /**
- * <code>_OT$activatedThreads</code> contains all threads for which this team instance is active.
- * key = activated thread
- * value = Boolean(true) for explicit activation | Boolean(false) for implicit activation.
- */
- private WeakHashMap<Thread, Boolean> _OT$activatedThreads = new WeakHashMap<Thread, Boolean>();
-
- /** This lock is used to protect activate/deactivate methods <strong>including</strong>
- * the calls to doRegistration/doUnregistration.
- */
- private Object _OT$registrationLock= new Object();
-
- /**
- * {@inheritDoc}
- */
- public void activate() {
- activate(Thread.currentThread());
- }
-
- /**
- * {@inheritDoc}
- */
- public void deactivate() {
- deactivate(Thread.currentThread());
- }
-
- /**
- * {@inheritDoc}
- */
- public void activate(Thread thread) {
- // acquire both locks to avoid incomplete execution:
- synchronized (this._OT$registrationLock) {
- synchronized (this) {
- if (thread.equals(ALL_THREADS)) {
- _OT$globalActive = true;
- _OT$lazyGlobalActiveFlag = true;
- TeamThreadManager.addGlobalActiveTeam(this);
- } else { // activation only for 'thread':
- // register 'thread' as active:
- _OT$activatedThreads.put(thread, Boolean.TRUE);
- }
- } // release this before calling synchronized base class methods
- doRegistration(); //$Debug(ActivateMethod)
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void deactivate(Thread thread) {
- // acquire both locks to avoid incomplete execution:
- synchronized (this._OT$registrationLock) {
- boolean shouldUnregister= false;
- synchronized(this) {
- if (thread.equals(ALL_THREADS)) {
- _OT$globalActive = false;
- TeamThreadManager.removeGlobalActiveTeam(this);
- // unregister all threads:
- _OT$activatedThreads.clear();
- shouldUnregister= true;
- } else { // deactivation only for 'thread':
- if (_OT$lazyGlobalActiveFlag) {
- // be eager now: activate for all (other) threads:
- _OT$activateForAllThreads();
- }
- // deactivate for 'thread', no longer active:
- _OT$activatedThreads.remove(thread);
- if (!_OT$lazyGlobalActiveFlag && _OT$activatedThreads.isEmpty()) {
- shouldUnregister= true;
- }
- }
- _OT$lazyGlobalActiveFlag = false;
- } // release this before calling synchronized base class methods
- if (shouldUnregister) //$Debug(DeactivateMethod)
- doUnregistration();
- }
- }
-
- public void deactivateForEndedThread(Thread thread) {
- synchronized (_OT$registrationLock) {
- boolean shouldUnregister= false;
- synchronized (this) {
- _OT$activatedThreads.remove(thread);
- if (!_OT$lazyGlobalActiveFlag && _OT$activatedThreads.isEmpty())
- shouldUnregister= true;
- }
- if (shouldUnregister)
- doUnregistration();
- }
- }
-
- private void _OT$activateForAllThreads() {
- HashSet threads = TeamThreadManager.getExistingThreads();
- Iterator it = threads.iterator();
- while (it.hasNext()) {
- Thread a_thread = (Thread) it.next();
- activate(a_thread); // use smaller activate version (no ALL_THREADS, no registerAtBases,...
- }
- }
-
- /**
- * This method is used for implicit activation in team-level methods.
- * Implicit activation only applies to the current thread.
- * Don't call it from client code.
- */
- public void _OT$implicitlyActivate() {
- synchronized (this._OT$registrationLock) {
- boolean shouldRegister= false;
- synchronized (this) {
- // this method is used for debugging purpose (team monitor)
- Thread currentThread = Thread.currentThread();
- if (!_OT$activatedThreads.containsKey(currentThread)) {
- // register 'thread' as active:
- _OT$activatedThreads.put(currentThread, Boolean.FALSE);
- shouldRegister= true;
- }
- // increment thread local implicit activation counter:
- int implActCount = (_OT$implicitActivationsPerThread.get()).intValue();
- _OT$implicitActivationsPerThread.set(Integer.valueOf(implActCount + 1 ));
- }
- if (shouldRegister) //$Debug(ImplicitActivateMethod)
- doRegistration();
- }
- }
-
- /**
- * This method is used for implicitly deactivation in team-level methods.
- * It respects explicit activation changes and nested calls to team-level methods.
- * Implicit deactivation only applies to the current thread.
- * Don't call it from client code.
- */
- public void _OT$implicitlyDeactivate() {
- synchronized (this._OT$registrationLock) {
- boolean shouldUnregister= false;
- synchronized(this) {
- // this method is used for debugging purpose (team monitor)
- Thread currentThread = Thread.currentThread();
- boolean explicitlyActivated = false;
- if (_OT$activatedThreads.containsKey(currentThread)) {
- explicitlyActivated = ((Boolean) _OT$activatedThreads.get(currentThread)).booleanValue();
- }
- if (!explicitlyActivated
- && !_OT$lazyGlobalActiveFlag // no explicit activation overriding the implicit one
- && ((_OT$implicitActivationsPerThread.get()).intValue() == 1)) // this is the last implicit activation
- {
- _OT$activatedThreads.remove(currentThread);
- if (_OT$activatedThreads.isEmpty()) // there are not other threads for which this theam is active
- {
- shouldUnregister= true;
- }
- }
- // decrement thread local implicit activaion counter:
- int implActCount = (_OT$implicitActivationsPerThread.get()).intValue();
- _OT$implicitActivationsPerThread.set(Integer.valueOf(implActCount - 1));
- }
- if (shouldUnregister) //$Debug(ImplicitDeactivateMethod)
- doUnregistration();
- }
- }
-
- /**
- * Define whether per-thread activation of this team should be inheritable
- * such that the team will be activated automatically for any new threads
- * that are spawned from a thread for which the team is already active at that time.
- *
- * @param inheritable whether or not activation should be inheritable to new threads
- */
- public void setInheritableActivation(boolean inheritable) {
- if (inheritable)
- TeamThreadManager.registerTeamForActivationInheritance(this);
- else
- TeamThreadManager.unRegisterTeamForActivationInheritance(this);
- }
-
- // not API (for use by the TeamThreadManager)
- public boolean internalIsActiveSpecificallyFor(Thread t) {
- return this._OT$activatedThreads.containsKey(t);
- }
-
- /**
- * {@inheritDoc}
- */
- public final boolean isActive() {
- return isActive(Thread.currentThread());
- }
-
- /**
- * {@inheritDoc}
- */
- public final boolean isActive(Thread thread) {
- if (thread.equals(ALL_THREADS)) {
- return _OT$globalActive;
- }
- if (_OT$lazyGlobalActiveFlag) {
- return true;
- } else {
- //if (!TeamThreadManager.getExistingThreads().contains(thread)) { // this thread is already finished!
- if (!thread.isAlive()) { // this thread is already finished!
- throw new IllegalThreadStateException("Called 'isActive(...)' for a thread which is no longer running!");
- }
- return _OT$activatedThreads.containsKey(thread);
- }
- }
-
-// ***** for restoring the activation state after a within block: ---->*****
- private static final int _OT$INACTIVE = 0;
- private static final int _OT$IMPLICIT_ACTIVE = 1;
- private static final int _OT$EXPLICIT_ACTIVE = 2;
-
- /**
- * {@inheritDoc}
- */
- public synchronized int _OT$saveActivationState() {
- int old_state = _OT$INACTIVE;
- if (_OT$lazyGlobalActiveFlag) {
- old_state = _OT$EXPLICIT_ACTIVE;
- } else {
- Thread current_thread = Thread.currentThread();
- if (_OT$activatedThreads.containsKey(current_thread)) {
- old_state = _OT$IMPLICIT_ACTIVE;
- if (((Boolean)_OT$activatedThreads.get(current_thread)).booleanValue()) {
- old_state = _OT$EXPLICIT_ACTIVE;
- }
- }
- }
- return old_state;
- }
-
- /**
- * {@inheritDoc}
- */
- public void _OT$restoreActivationState(int old_state) {
- synchronized (_OT$registrationLock) {
- if (old_state == _OT$INACTIVE) // team was inactive before:
- deactivate();
- else { // team was active before: has to be reactivated:
- boolean explicit = (old_state == _OT$EXPLICIT_ACTIVE);
- synchronized (this) {
- _OT$activatedThreads.put(Thread.currentThread(), Boolean.valueOf(explicit));
- }
- doRegistration();
- }
- }
- }
-// ***** <----for restoring the activation state after a within block. *****
-
-
- private void doRegistration() {
- if (_OT$registrationState == _OT$UNREGISTERED) {
- // register the team at the TeamManager
- TeamManager.handleTeamStateChange(this, TeamManager.TeamStateChange.REGISTER);
- _OT$registrationState = _OT$REGISTERED;
- }
- }
-
- private void doUnregistration() {
- if (_OT$registrationState == _OT$REGISTERED) {
- // unregister the team at the TeamManager
- TeamManager.handleTeamStateChange(this, TeamManager.TeamStateChange.UNREGISTER);
- _OT$registrationState = _OT$UNREGISTERED;
- }
- }
-
- /**
- * This method will be implemented by generated code in subteams.
- * It registers the team at every base playing one of its roles.
- * Don't call it from client code.
- */
- public void _OT$registerAtBases() {}
-
- /**
- * This method will be implemented by generated code in subteams.
- * It unregisters the team from every base playing one of its roles.
- * Don't call it from client code.
- */
- public void _OT$unregisterFromBases() {}
-
- //public int _OT$activationState = -1; // TODO: remove usage of this from generated code
-
-
- /**
- * {@inheritDoc}
- */
- public boolean hasRole(Object aBase) {
- // overriding method to be generated by the compiler for each team with bound roles.
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean hasRole(Object aBase, Class<?> roleType) throws IllegalArgumentException {
- // overriding method to be generated by the compiler for each team with bound roles.
- throw new IllegalArgumentException("No such bound role type in this team: "+roleType.getName());
- }
-
- /**
- * {@inheritDoc}
- */
- public Object getRole(Object aBase) {
- // overriding method to be generated by the compiler for each team with bound roles.
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public <T> T getRole(Object aBase, Class<T> roleType) throws IllegalArgumentException {
- // overriding method to be generated by the compiler for each team with bound roles.
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public Object[] getAllRoles() {
- // overriding method to be generated by the compiler for each team with bound roles.
- return new Object[0];
- }
-
- /**
- * {@inheritDoc}
- */
- public <T> T[] getAllRoles(Class<T> roleType) throws IllegalArgumentException {
- // overriding method to be generated by the compiler for each team with bound roles.
- throw new IllegalArgumentException("Class org.objectteams.Team has no bound roles.");
- }
-
- /** Internal variable to be set from generated code. */
- private boolean _OT$isExecutingCallin = false;
-
- /**
- * Method only for internal use by generated code.
- */
- public boolean _OT$setExecutingCallin(boolean newFlag) {
- boolean oldVal = _OT$isExecutingCallin;
- _OT$isExecutingCallin = newFlag;
- return oldVal;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isExecutingCallin() {
- return _OT$isExecutingCallin;
- }
-
- /**
- * {@inheritDoc}
- */
- public void unregisterRole(Object aRole) {
- // overriding method to be generated by the compiler for each team with bound roles.
- }
-
- /**
- * {@inheritDoc}
- */
- public void unregisterRole(Object aRole, Class<?> roleType) throws IllegalArgumentException {
- // overriding method to be generated by the compiler for each team with bound roles.
- }
-
- @Override
- protected void finalize() throws Throwable {
- // nop, hook for the debugger
- @SuppressWarnings("unused")
- int i= 2+3; // Note: body must not be empty for debuggger to be able to stop.
- } // $Debug(FinalizeMethod)
-
- /**
- * If a serializable team wishes to persist its global activation status it must
- * call this method from its writeObject() method and correspondingly call
- * {@link #readGlobalActivationState(ObjectInputStream)} from its readObject().
- */
- protected void writeGlobalActivationState(ObjectOutputStream out) throws IOException {
- out.writeBoolean(this._OT$globalActive);
- }
- /**
- * If a serializable team wishes to persist its global activation status it must
- * call this method from its readObject() method and correspondingly call
- * {@link #writeGlobalActivationState(ObjectOutputStream)} from its writeObject().
- * If a team is restored that was globally active when serialized, it will be activated
- * correspondingly during deserialization when this method is called.
- */
- protected void readGlobalActivationState(ObjectInputStream in) throws IOException {
- this._OT$globalActive = in.readBoolean();
- if (this._OT$globalActive) {
- this._OT$lazyGlobalActiveFlag = true;
- this.doRegistration();
- }
- }
- /**
- * Serializable teams must invoke this method once from their readObject() method
- * in order to re-initialize internal data structures.
- */
- protected void restore() { /* empty; implementation will be generated for each serializable sub-class. */ }
- /**
- * Serializable teams must invoke this method from their readObject() method
- * for each role that has been retrieved and shall be re-registered for this team.
- */
- protected void restoreRole(Class<?> clazz, Object role) { /* empty; implementation will be generated for each serializable sub-class. */ }
-
- /**
- * This method is the first part of the new chaining wrapper.
- * It should be called from the generated client code.
- *
- * @param baze the current base object
- * @param teams the current team objects
- * @param idx the index of the current team in teams
- * @param callinIds an array of ids, that are unique in the team
- * for a base method in a base class
- * @param boundMethodId an unique id for a base method in the base class.
- * This id is needed for a base call.
- * @param args packed arguments.
- * @return possibly boxed result
- */
- public Object _OT$callAllBindings(IBoundBase baze, ITeam[] teams,int idx,int[] callinIds, int boundMethodId, Object[] args)
- {
-
-
- this._OT$callBefore(baze, callinIds[idx], boundMethodId, args);
-
- Object res = this._OT$callReplace(baze, teams, idx, callinIds, boundMethodId, args);
-
- this._OT$callAfter(baze, callinIds[idx], boundMethodId, args, res); // make result available to param mappings!
-
- return res;
- }
-
- /**
- * This method calls the next team or a base method,
- * if there are no more active teams for a joinpoint
- *
- * @param baze the current base object
- * @param teams the current base object
- * @param idx the index of the current team in teams, also points into callinIds, i.e., both lists run synchroneously.
- * @param callinIds an array of ids, that are unique in the team
- * for a base method in a base class
- * @param boundMethodId an unique id for a base method in the base class.
- * This id is needed for a base call.
- * @param args original packed arguments.
- * @param baseCallArgs packed arguments as provided to the base call.
- * @return possibly boxed result
- */
- public Object _OT$callNext(IBoundBase baze, ITeam[] teams, int idx, int[] callinIds, int boundMethodId, Object[] args, Object[] baseCallArgs)
- {
-//System.out.println("callNext idx="+idx);
-//for (Team t : teams)
-// System.out.println("team="+t);
- // Are there still active teams?
- if (idx+1 < teams.length) {
- // Yes, so call the next team/callin
- return teams[idx+1]._OT$callAllBindings(baze, teams, idx+1, callinIds, boundMethodId, args);
- } else {
- //No, call the base method
- if (baze == null) {
- //handle base call to a static base method
- return teams[idx]._OT$callOrigStatic(callinIds[idx], boundMethodId, args);
- } else {
-//System.out.println("callOrig: "+boundMethodId);
- return baze._OT$callOrig(boundMethodId, args);
-//Object result = baze.callOrig(boundMethodId, args);
-//System.out.println("->"+result);
-//return result;
- }
- }
- }
-
- /**
- * Executes all before callins for a given callin id.
- * Must be overridden by a team, if the team gets replace callins.
- *
- * @param baze the current base object
- * @param callinId the current callin id
- * @param boundMethodId an unique id for a base method in the base class.
- * This id is needed for a base call.
- * @param args packed arguments.
- * @return possibly boxed result
- */
- public void _OT$callBefore(IBoundBase baze, int callinId, int boundMethodId, Object[] args) {
- // nop; override with code from before callin bindings.
- }
-
- /**
- * Executes all after callins for a given callin id.
- * Must be overridden by a team, if the team gets replace callins.
- *
- * @param baze the current base object
- * @param callinId the current callin id
- * @param boundMethodId an unique id for a base method in the base class.
- * This id is needed for a base call.
- * @param args packed arguments.
- * @param result the result of the base method. Could be used by after callins
- */
- public void _OT$callAfter(IBoundBase baze, int callinId, int boundMethodId, Object[] args, Object result) {
- // nop; override with code from after callin bindings.
- }
-
- /**
- * Execute replace callins of the team for the current callin id.
- * Must be overridden by a team, if the team has got replace callins.
- *
- * @param baze the current base object
- * @param teams the current base object
- * @param idx the index of the current team in teams
- * @param callinIds an array of ids, that are unique in the team
- * for a base method in a base class
- * @param boundMethodId an unique id for a base method in the base class.
- * This id is needed for a base call.
- * @param args packed arguments.
- * @return possibly boxed result
- */
- public Object _OT$callReplace(IBoundBase baze, ITeam[] teams, int idx, int[] callinIds, int boundMethodId, Object[] args) {
- // default; override with code from replace callin bindings.
- return _OT$callNext(baze, teams, idx, callinIds, boundMethodId, args, null);
- }
-
- /**
- * Calls the method callOrigStatic of a concrete class dependend on the
- * given callin id.
- * Must be overridden in a team, if the team has got base calls
- * to static base methods
- * @param callinId
- * @param boundMethodId
- * @param args
- * @return
- */
- public Object _OT$callOrigStatic(int callinId, int boundMethodId, Object[] args) {
- return null;
- }
-}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/TeamThreadManager.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/TeamThreadManager.java
deleted file mode 100644
index e6bc9db..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/TeamThreadManager.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/**********************************************************************
- * This file is part of "Object Teams Dynamic Runtime Environment"
- *
- * Copyright 2006-2010 Berlin Institute of Technology, Germany, and others.
- *
- * 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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Berlin Institute of Technology - Initial API and implementation
- **********************************************************************/
-package org.objectteams;
-
-import java.util.HashSet;
-import java.util.WeakHashMap;
-
-
-/**
- * This class is for internal use, only.
- *
- * Maintain information about existing threads as to manage
- * team activation per thread vs. globally.
- *
- * @author Chistine Hundt
- * @author Stephan Herrmann
- */
-public class TeamThreadManager {
-
- private static Object token = new Object();
-
- private static HashSet<ITeam> globalActiveTeams = new HashSet<ITeam>();
- private static WeakHashMap<ITeam,Object> teamsWithActivationInheritance = new WeakHashMap<ITeam,Object>();
- private static HashSet<Thread> existingThreads = new HashSet<Thread>();
-
- public static boolean newThreadStarted(boolean isMain, Thread parent) {
- Thread currentThread = Thread.currentThread();
- // already registered?
- if (existingThreads.contains(currentThread))
- return false;
- // workaround for application hang on Mac OS with Apple JVM:
- if (System.getProperty("os.name").startsWith("Mac"))
- if (currentThread.getName().equals("AWT-Shutdown"))
- return false;
-
- ITeam[] globalTeams;
- ITeam[] inheritableTeams;
- synchronized (TeamThreadManager.class) {
- boolean isFirst = existingThreads.isEmpty();
- existingThreads.add(currentThread);
- if (isMain || isFirst) {
- for (Thread thread : fetchSystemThreads(currentThread))
- if (thread != null)
- existingThreads.add(thread);
- }
-
- globalTeams = globalActiveTeams.toArray(new ITeam[globalActiveTeams.size()]);
- inheritableTeams = teamsWithActivationInheritance.keySet().toArray(new ITeam[teamsWithActivationInheritance.size()]);
- }
- // activate teams outside synchronized block:
- for (ITeam t : globalTeams)
- t.activate(currentThread); // small version? global -> already registered...!
- if (parent != null)
- for (ITeam t : inheritableTeams)
- if (t.internalIsActiveSpecificallyFor(parent))
- t.activate(currentThread); // pass activation from parent to child thread
- return true;
- }
-
- /* Fetch all existing threads existing at this point in time. Result array is padded with nulls. */
- private static Thread[] fetchSystemThreads(Thread currentThread) {
- ThreadGroup group = currentThread.getThreadGroup();
- {
- ThreadGroup parentGroup;
- while ((parentGroup= group.getParent()) != null)
- group = parentGroup;
- }
- int size = group.activeCount();
- Thread[] allThreads;
- do {
- size += 2;
- allThreads = new Thread[size];
- } while (group.enumerate(allThreads) == size);
- return allThreads;
- }
-
- public static void threadEnded() {
- ITeam[] teamsToDeactivate = internalThreadEnded();
- // + remove per thread activation:
- for (ITeam t : teamsToDeactivate)
- //t.deactivate(Thread.currentThread()); // small version?
- t.deactivateForEndedThread(Thread.currentThread());
- }
- private synchronized static ITeam[] internalThreadEnded() {
- existingThreads.remove(Thread.currentThread());
- // fetch all global active teams for deactivation:
- return globalActiveTeams.toArray(new ITeam[globalActiveTeams.size()]);
- }
-
- public synchronized static void addGlobalActiveTeam(ITeam t) {
- globalActiveTeams.add(t);
- }
-
- public synchronized static void removeGlobalActiveTeam(ITeam t) {
- globalActiveTeams.remove(t);
- }
-
- public static HashSet<Thread> getExistingThreads() {
- return existingThreads;
- }
- public static void registerTeamForActivationInheritance(ITeam aTeam) {
- teamsWithActivationInheritance.put(aTeam,token);
- }
- public static void unRegisterTeamForActivationInheritance(ITeam aTeam) {
- teamsWithActivationInheritance.remove(aTeam);
- }
-
-}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/UnsupportedFeatureException.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/UnsupportedFeatureException.java
deleted file mode 100644
index 24dd1bf..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/UnsupportedFeatureException.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**********************************************************************
- * This file is part of "Object Teams Dynamic Runtime Environment"
- *
- * Copyright 2004, 2010 Berlin Institute of Technology, Germany, and others.
- *
- * 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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Berlin Institute of Technology - Initial API and implementation
- **********************************************************************/
-package org.objectteams;
-
-/**
- * @author resix
- */
-public class UnsupportedFeatureException extends RuntimeException {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private static final String _bugmsg = "\nThe program encountered an unsupported situation! ";
-
- /**
- *
- */
- public UnsupportedFeatureException() {
- super(_bugmsg);
- }
-
- /**
- * @param message
- */
- public UnsupportedFeatureException(String message) {
- super(_bugmsg + "\n" + message);
- StackTraceElement[] ste = new StackTraceElement[0];
- setStackTrace(ste);
- }
-
- /**
- * @param cause
- */
- public UnsupportedFeatureException(Throwable cause) {
- super(_bugmsg + cause.toString());
- }
-
- /**
- * @param message
- * @param cause
- */
- public UnsupportedFeatureException(String message, Throwable cause) {
- super(_bugmsg + message/*+cause.toString()*/);
- }
-}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/WrongRoleException.java b/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/WrongRoleException.java
deleted file mode 100644
index 467c4a0..0000000
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/objectteams/WrongRoleException.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**********************************************************************
- * This file is part of "Object Teams Dynamic Runtime Environment"
- *
- * Copyright 2003, 2010 Berlin Institute of Technology, Germany, and others.
- *
- * 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
- *
- * Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
- * Contributors:
- * Berlin Institute of Technology - Initial API and implementation
- **********************************************************************/
-package org.objectteams;
-
-/**
- * This exception is thrown by the OT/J infra structure if a role for a given base object
- * was requested during lifting, but a role with an incompatible type was already
- * registered for that base object. Can only happen if a compile time warning occurred.
- * @author Stephan Herrmann
- */
-public class WrongRoleException extends RuntimeException {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private Class<?> clazz;
- private Object base;
- private Object role;
-
- /**
- * @param clazz
- * @param base
- * @param role
- */
- public WrongRoleException (Class<?> clazz, Object base, Object role) {
- this.clazz = clazz;
- this.base = base;
- this.role = role;
- }
-
- @Override
- public String getMessage() {
- String baseClazz = base.getClass().getName();
- String roleClazz = role.getClass().getName();
- return "The compiler has warned you about ambiguous role bindings.\n"
- + "Now lifting to " + clazz
- + " fails with the following objects\n"
- + "(see OT/J language definition para. 2.3.4(d)):\n"
- + "Provided:\n Base object: " + base + "\n" + " Base type: "
- + baseClazz + "\n"
- + "Found in cache:\n Role object: " + role + "\n"
- + " Role type: " + roleClazz;
- }
-}
diff --git a/plugins/org.eclipse.objectteams.runtime/src/org/objectteams/ITeamManager.java b/plugins/org.eclipse.objectteams.runtime/src/org/objectteams/ITeamManager.java
index b957ad9..1e88b02 100644
--- a/plugins/org.eclipse.objectteams.runtime/src/org/objectteams/ITeamManager.java
+++ b/plugins/org.eclipse.objectteams.runtime/src/org/objectteams/ITeamManager.java
@@ -16,7 +16,7 @@
package org.objectteams;
/**
- * This interface encapsulates the OTDRE for callbacks from {@link Team}.
+ * This interface encapsulates the OTDRE for callbacks from class {@link Team}.
* NOT API.
*/
public interface ITeamManager {
@@ -26,5 +26,5 @@
UNREGISTER
}
- void handleTeamStateChange(Team aTeam, TeamStateChange register);
+ void handleTeamStateChange(ITeam aTeam, TeamStateChange register);
}