From 8265bac2b20bce3d1c9e0040ad6114c30b13d42f Mon Sep 17 00:00:00 2001 From: Patrick Linskey Date: Fri, 31 Aug 2007 21:46:59 +0000 Subject: [PATCH] Minor logging correction; flow control correction. 'svn merge -c 571599 ../../trunk' git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/1.0.x@571608 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/openjpa/enhance/ClassRedefiner.java | 7 ++++--- .../enhance/ManagedClassSubclasser.java | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) 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); + } } }