Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2017-01-08 08:36:21 -0500
committerStephan Herrmann2017-01-15 13:26:56 -0500
commitf5640ab06d952bd815fb5da104c1950a36094918 (patch)
tree5a4388a42f84a2926d6a3c721dc804742eb019d8
parenteb57078346e472b290fac58398140dd3e003520f (diff)
downloadorg.eclipse.objectteams-f5640ab06d952bd815fb5da104c1950a36094918.tar.gz
org.eclipse.objectteams-f5640ab06d952bd815fb5da104c1950a36094918.tar.xz
org.eclipse.objectteams-f5640ab06d952bd815fb5da104c1950a36094918.zip
Bug 510077: [otdre] More logging of errors during weaving
-rw-r--r--plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/DelegatingTransformer.java2
-rw-r--r--plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/OTWeavingHook.java11
-rw-r--r--plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/AbstractBoundClass.java27
-rw-r--r--plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmWritableBoundClass.java16
-rw-r--r--plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/transformer/jplis/ObjectTeamsTransformer.java12
-rw-r--r--plugins/org.eclipse.objectteams.runtime/META-INF/MANIFEST.MF8
-rw-r--r--plugins/org.eclipse.objectteams.runtime/src/org/eclipse/objectteams/runtime/IReweavingTask.java6
-rw-r--r--releng/map/otdt.map.in2
8 files changed, 57 insertions, 27 deletions
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
index 32f2aea7a..cf12392e2 100644
--- 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
@@ -78,7 +78,7 @@ public abstract class DelegatingTransformer {
public Collection<String> fetchAdaptedBases() {
return transformer.fetchAdaptedBases();
}
- public byte[] transform(final Bundle bundle, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] bytes) {
+ public byte[] transform(final Bundle bundle, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] bytes) throws IllegalClassFormatException {
// TODO provide classID
return transformer.transform(getBundleLoader(bundle), className, className.replace('.', '/'), classBeingRedefined, bytes);
}
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 282d52600..631c88410 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
@@ -480,8 +480,15 @@ System.err.println("OT/Equinox: ot.weaving="+weaving);
}
beingDefined.remove(className);
IReweavingTask task = pendingReweavingTasks.remove(className);
- if (task != null)
- task.reweave(wovenClass.getDefinedClass());
+ if (task != null) {
+ try {
+ task.reweave(wovenClass.getDefinedClass());
+ } catch (IllegalClassFormatException e) {
+ log(e, "Failed to reweave class "+wovenClass.getClassName());
+ TransformerPlugin.flushLog();
+ return;
+ }
+ }
instantiateScheduledTeams(className);
TransformerPlugin.flushLog();
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 732f8cc1e..ac8aaf38d 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
@@ -16,6 +16,7 @@
**********************************************************************/
package org.eclipse.objectteams.otredyn.bytecode;
+import java.lang.instrument.IllegalClassFormatException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -365,8 +366,9 @@ public abstract class AbstractBoundClass implements IBoundClass {
* Add the empty method access
* Add the empty method accessStatic
* Add the empty method callAllBindings
+ * @throws IllegalClassFormatException various bytecode problems, e.g., unexpected RET instruction etc.
*/
- public void transformAtLoadTime() {
+ public void transformAtLoadTime() throws IllegalClassFormatException {
handleTaskList(null);
}
@@ -623,8 +625,9 @@ public abstract class AbstractBoundClass implements IBoundClass {
* Handle all open weaving tasks for this class.
* It redefines the class, if it is not called while loading
* @param definedClass previously defined class if available
+ * @throws IllegalClassFormatException various bytecode problems, e.g., unexpected RET instruction etc.
*/
- public void handleTaskList(Class<?> definedClass) {
+ public void handleTaskList(Class<?> definedClass) throws IllegalClassFormatException {
if (isTransformationActive()) return;
if (this.isUnweavable)
@@ -828,7 +831,7 @@ public abstract class AbstractBoundClass implements IBoundClass {
for (final AbstractBoundClass affected : affectedClasses)
if (affected.isLoaded) {
IReweavingTask task = new IReweavingTask() {
- @Override public void reweave(Class<?> definedClass) {
+ @Override public void reweave(Class<?> definedClass) throws IllegalClassFormatException {
affected.handleTaskList(definedClass);
}
};
@@ -887,7 +890,11 @@ public abstract class AbstractBoundClass implements IBoundClass {
if (task == null)
task = new WeavingTask(type, binding.getMemberName(), binding.getMemberSignature(),
binding.getBaseFlags(), binding.isHandleCovariantReturn(), binding.requiresBaseSuperCall());
- addWeavingTask(task, false);
+ try {
+ addWeavingTask(task, false);
+ } catch (IllegalClassFormatException e) {
+ e.printStackTrace(); // we're called from TeamManager, which can neither log nor handle exceptions
+ }
}
@Override
@@ -899,11 +906,15 @@ public abstract class AbstractBoundClass implements IBoundClass {
public synchronized void commitTransaction() {
--this.transactionCount;
if (this.transactionCount == 0 && this.isLoaded) {
- handleTaskList(null);
+ try {
+ handleTaskList(null);
+ } catch (IllegalClassFormatException e) {
+ e.printStackTrace(); // we're called from TeamManager, which can neither log nor handle exceptions
+ }
}
}
- private void addWeavingTask(WeavingTask task, boolean standBy) {
+ private void addWeavingTask(WeavingTask task, boolean standBy) throws IllegalClassFormatException {
boolean isNewTask = addWeavingTaskLazy(task);
if (this.isLoaded && isNewTask && !standBy && this.transactionCount == 0) {
@@ -1160,9 +1171,9 @@ public abstract class AbstractBoundClass implements IBoundClass {
protected abstract void startTransformation();
- protected abstract void endTransformation(Class<?> definedClass);
+ protected abstract void endTransformation(Class<?> definedClass) throws IllegalClassFormatException;
- protected abstract void superTransformation(Class<?> definedClass);
+ protected abstract void superTransformation(Class<?> definedClass) throws IllegalClassFormatException;
protected abstract void prepareAsPossibleBaseClass();
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmWritableBoundClass.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmWritableBoundClass.java
index 76788ffbf..42be31d15 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmWritableBoundClass.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmWritableBoundClass.java
@@ -19,6 +19,7 @@ package org.eclipse.objectteams.otredyn.bytecode.asm;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.lang.instrument.IllegalClassFormatException;
import java.util.ArrayList;
import java.util.List;
@@ -138,9 +139,10 @@ class AsmWritableBoundClass extends AsmBoundClass {
/**
* Executes all pending transformations.
+ * @throws IllegalClassFormatException various bytecode problems, e.g., unexpected RET instruction etc.
*/
@Override
- protected void endTransformation(final Class<?> definedClass) {
+ protected void endTransformation(final Class<?> definedClass) throws IllegalClassFormatException {
assert (isTransformationActive) : "No transformation active";
if (multiAdapter == null || nodes == null)
@@ -148,13 +150,11 @@ class AsmWritableBoundClass extends AsmBoundClass {
if (multiAdapter.hasVisitors() || !nodes.isEmpty()) {
// //TODO (ofra): Do everything in one transformation
// Do all transformation with the Core API of ASM
-// try {
+ try {
reader.accept(multiAdapter, ClassReader.SKIP_FRAMES);
-// } catch (RuntimeException e) {
-// System.err.println("Cannot transform class "+this+":");
-// e.printStackTrace();
-// return;
-// }
+ } catch (RuntimeException e) {
+ throw new IllegalClassFormatException("Cannot transform class "+this+":"+e.getMessage());
+ }
setBytecode(writer.toByteArray());
//Do all transformations with the Tree API of ASM
for (AbstractTransformableClassNode node : nodes) {
@@ -215,7 +215,7 @@ class AsmWritableBoundClass extends AsmBoundClass {
releaseBytecode();
}
- protected void superTransformation(Class<?> definedClass) {
+ protected void superTransformation(Class<?> definedClass) throws IllegalClassFormatException {
AbstractTeam mySuper = getSuperclass();
if (mySuper != null && mySuper.isLoaded()) {
boolean superNeedsWeaving = false;
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 f97218b2f..be8edf9d8 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
@@ -19,6 +19,7 @@ import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.instrument.ClassFileTransformer;
+import java.lang.instrument.IllegalClassFormatException;
import java.security.ProtectionDomain;
import java.util.Collection;
import java.util.HashSet;
@@ -63,11 +64,16 @@ public class ObjectTeamsTransformer implements ClassFileTransformer {
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined,
ProtectionDomain protectionDomain, byte[] classfileBuffer)
{
- return transform(loader, className, className, classBeingRedefined, classfileBuffer);
+ try {
+ return transform(loader, className, className, classBeingRedefined, classfileBuffer);
+ } catch (IllegalClassFormatException e) {
+ e.printStackTrace();
+ return classfileBuffer;
+ }
}
public byte[] transform(ClassLoader loader, String className, String classId, Class<?> classBeingRedefined,
- byte[] classfileBuffer) {
+ byte[] classfileBuffer) throws IllegalClassFormatException {
if (loader == null)
loader = ClassLoader.getSystemClassLoader();
@@ -107,6 +113,8 @@ public class ObjectTeamsTransformer implements ClassFileTransformer {
clazz.transformAtLoadTime();
classfileBuffer = clazz.getBytecode();
+ } catch (IllegalClassFormatException e) {
+ throw e; // expected, propagate to caller (OT/Equinox?)
} catch(Throwable t) {
t.printStackTrace();
}
diff --git a/plugins/org.eclipse.objectteams.runtime/META-INF/MANIFEST.MF b/plugins/org.eclipse.objectteams.runtime/META-INF/MANIFEST.MF
index dba062a60..b45f8f5be 100644
--- a/plugins/org.eclipse.objectteams.runtime/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.objectteams.runtime/META-INF/MANIFEST.MF
@@ -2,13 +2,13 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.objectteams.runtime
-Bundle-Version: 2.5.0.qualifier
+Bundle-Version: 2.5.3.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Require-Bundle: org.eclipse.jdt.annotation;bundle-version="[1.1.0,2.0.0)";resolution:=optional
-Export-Package: org.eclipse.objectteams.otredyn.runtime;version="2.5.0",
- org.eclipse.objectteams.runtime;version="2.5.0",
- org.objectteams;version="2.5.0"
+Export-Package: org.eclipse.objectteams.otredyn.runtime;version="2.5.3",
+ org.eclipse.objectteams.runtime;version="2.5.3",
+ org.objectteams;version="2.5.3"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ClassPath: .
diff --git a/plugins/org.eclipse.objectteams.runtime/src/org/eclipse/objectteams/runtime/IReweavingTask.java b/plugins/org.eclipse.objectteams.runtime/src/org/eclipse/objectteams/runtime/IReweavingTask.java
index a52c4474d..b7c574fed 100644
--- a/plugins/org.eclipse.objectteams.runtime/src/org/eclipse/objectteams/runtime/IReweavingTask.java
+++ b/plugins/org.eclipse.objectteams.runtime/src/org/eclipse/objectteams/runtime/IReweavingTask.java
@@ -15,6 +15,8 @@
*/
package org.eclipse.objectteams.runtime;
+import java.lang.instrument.IllegalClassFormatException;
+
import org.eclipse.jdt.annotation.Nullable;
/**
@@ -26,6 +28,8 @@ public interface IReweavingTask {
* Reweave the class represented by this task.
* @param definedClass for convenience the previously defined class can
* be passed in as an argument.
+ * @throws IllegalClassFormatException various problems during bytecode transformation, e.g.,
+ * unexpected / illegal byte codes (like RET) encountered.
*/
- public void reweave(@Nullable Class<?> definedClass);
+ public void reweave(@Nullable Class<?> definedClass) throws IllegalClassFormatException;
}
diff --git a/releng/map/otdt.map.in b/releng/map/otdt.map.in
index f77833ce0..1def9fb41 100644
--- a/releng/map/otdt.map.in
+++ b/releng/map/otdt.map.in
@@ -19,7 +19,7 @@ plugin@org.eclipse.objectteams.otdt.ui=GIT,repo=git://git.eclipse.org/gitroot/ob
plugin@org.eclipse.objectteams.otdt.doc=GIT,repo=git://git.eclipse.org/gitroot/objectteams/org.eclipse.objectteams.git,path=plugins/org.eclipse.objectteams.otdt.doc,tag=builds/201606070956
!plugin@org.eclipse.objectteams.otdt.metrics=GIT,repo=git://git.eclipse.org/gitroot/objectteams/org.eclipse.objectteams.git,path=plugins/org.eclipse.objectteams.otdt.metrics,tag=builds/201101290806
-plugin@org.eclipse.objectteams.runtime=GIT,repo=git://git.eclipse.org/gitroot/objectteams/org.eclipse.objectteams.git,path=plugins/org.eclipse.objectteams.runtime,tag=builds/201606070956
+plugin@org.eclipse.objectteams.runtime=GIT,repo=git://git.eclipse.org/gitroot/objectteams/org.eclipse.objectteams.git,path=plugins/org.eclipse.objectteams.runtime
plugin@org.eclipse.objectteams.otre=GIT,repo=git://git.eclipse.org/gitroot/objectteams/org.eclipse.objectteams.git,path=plugins/org.eclipse.objectteams.otre,tag=builds/201606070956
plugin@org.eclipse.objectteams.otredyn=GIT,repo=git://git.eclipse.org/gitroot/objectteams/org.eclipse.objectteams.git,path=plugins/org.eclipse.objectteams.otredyn,tag=branches/maintenance/OTDT_2.5.x
!the following is also referenced in otdt.doc/buildDoc.xml (plugin-name without version):

Back to the top