diff --git a/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/ClassRedefiner.java b/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/ClassRedefiner.java
index ac6d782dc..fa76f87be 100644
--- a/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/ClassRedefiner.java
+++ b/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/ClassRedefiner.java
@@ -55,14 +55,15 @@ public class ClassRedefiner {
/**
* For each element in classes
, this method will redefine
* all the element's methods such that field accesses are intercepted
- * in-line.
+ * in-line. If {@link #canRedefineClasses()} returns false
,
+ * this method is a no-op.
*/
public static void redefineClasses(OpenJPAConfiguration conf,
final Map classes) {
- Log log = conf.getLog(OpenJPAConfiguration.LOG_ENHANCE);
- if (classes == null || classes.size() == 0)
+ if (classes == null || classes.size() == 0 || !canRedefineClasses())
return;
+ Log log = conf.getLog(OpenJPAConfiguration.LOG_ENHANCE);
Instrumentation inst = null;
ClassFileTransformer t = null;
try {
diff --git a/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/ManagedClassSubclasser.java b/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/ManagedClassSubclasser.java
index 6d6305e91..d0365e201 100644
--- a/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/ManagedClassSubclasser.java
+++ b/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/ManagedClassSubclasser.java
@@ -104,10 +104,10 @@ public class ManagedClassSubclasser {
boolean redefine = ClassRedefiner.canRedefineClasses();
if (redefine)
- log.info(_loc.get("enhance-and-subclass-no-redef-start",
+ log.info(_loc.get("enhance-and-subclass-and-redef-start",
classes));
else
- log.info(_loc.get("enhance-and-subclass-and-redef-start",
+ log.info(_loc.get("enhance-and-subclass-no-redef-start",
classes));
final Map map = new HashMap();
@@ -139,12 +139,14 @@ public class ManagedClassSubclasser {
unspecified = collectRelatedUnspecifiedTypes(enhancer.getMetaData(),
classes, unspecified);
- enhancer.run();
- try {
- enhancer.record();
- } catch (IOException e) {
- // our impl of BytecodeWriter doesn't throw IOException
- throw new InternalException(e);
+ int runResult = enhancer.run();
+ if (runResult == PCEnhancer.ENHANCE_PC) {
+ try {
+ enhancer.record();
+ } catch (IOException e) {
+ // our impl of BytecodeWriter doesn't throw IOException
+ throw new InternalException(e);
+ }
}
}