Bug 510204 - Temporary StdErrLogger code removal
           - Fixed java.lang.ClassCircularityError: org/eclipse/persistence/internal/weaving/WeaverLogger

Signed-off-by: Tomas Kraus <tomas.kraus@oracle.com>
Reviewed By: Lukas Jungmann <lukas.jungmann@oracle.com>
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/descriptors/PersistenceObjectAttributeAccessor.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/descriptors/PersistenceObjectAttributeAccessor.java
index c33ca03..34c818d 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/descriptors/PersistenceObjectAttributeAccessor.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/descriptors/PersistenceObjectAttributeAccessor.java
@@ -12,56 +12,21 @@
  ******************************************************************************/
 package org.eclipse.persistence.internal.descriptors;
 
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-
 import org.eclipse.persistence.exceptions.DescriptorException;
-import org.eclipse.persistence.internal.logging.StdErrLogger;
-import org.eclipse.persistence.internal.security.PrivilegedAccessHelper;
-import org.eclipse.persistence.internal.security.PrivilegedGetClassLoaderForClass;
-import org.eclipse.persistence.internal.security.PrivilegedGetClassLoaderFromCurrentThread;
-import org.eclipse.persistence.logging.SessionLog;
 
 /**
  * Used with weaving to access attributes without using reflection.
  */
 public class PersistenceObjectAttributeAccessor extends InstanceVariableAttributeAccessor {
 
-    /** Cache weaver logger finest level settings. */
-    private final boolean shouldLogFinest;
-
     public PersistenceObjectAttributeAccessor(String attributeName) {
         this.attributeName = attributeName.intern();
-        // PERF: Cache weaver logger finest level settings. It won't allow to change logger settings on the fly
-        // but it's less evil than evaluating it with every single getter/setter call.
-        shouldLogFinest = StdErrLogger.shouldLog(SessionLog.FINEST, SessionLog.WEAVER);
     }
 
     /**
      * Returns the value of the attribute on the specified object.
      */
     public Object getAttributeValueFromObject(Object object) {
-        if (shouldLogFinest) {
-            ClassLoader contextClassLoader;
-            ClassLoader objectClassLoader;
-            if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
-                try {
-                    contextClassLoader = AccessController.doPrivileged(
-                            new PrivilegedGetClassLoaderFromCurrentThread());
-                    objectClassLoader = AccessController.doPrivileged(
-                            new PrivilegedGetClassLoaderForClass(object.getClass()));
-                } catch (PrivilegedActionException ex) {
-                    throw (RuntimeException) ex.getCause();
-                }
-            } else {
-                contextClassLoader = Thread.currentThread().getContextClassLoader();
-                objectClassLoader = object.getClass().getClassLoader();
-            }
-            StdErrLogger.log(SessionLog.FINEST, SessionLog.WEAVER, "weaving_call_persistence_get",
-                    object.getClass().getName(),
-                            Integer.toHexString(System.identityHashCode(contextClassLoader)),
-                            Integer.toHexString(System.identityHashCode(objectClassLoader)));
-        }
         return ((PersistenceObject)object)._persistence_get(this.attributeName);
     }
 
@@ -78,27 +43,6 @@ public void initializeAttributes(Class descriptorClass) throws DescriptorExcepti
      * Sets the value of the instance variable in the object to the value.
      */
     public void setAttributeValueInObject(Object object, Object value) {
-        if (shouldLogFinest) {
-            ClassLoader contextClassLoader;
-            ClassLoader objectClassLoader;
-            if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
-                try {
-                    contextClassLoader = AccessController.doPrivileged(
-                            new PrivilegedGetClassLoaderFromCurrentThread());
-                    objectClassLoader = AccessController.doPrivileged(
-                            new PrivilegedGetClassLoaderForClass(object.getClass()));
-                } catch (PrivilegedActionException ex) {
-                    throw (RuntimeException) ex.getCause();
-                }
-            } else {
-                contextClassLoader = Thread.currentThread().getContextClassLoader();
-                objectClassLoader = object.getClass().getClassLoader();
-            }
-            StdErrLogger.log(SessionLog.FINEST, SessionLog.WEAVER, "weaving_call_persistence_set",
-                    object.getClass().getName(),
-                            Integer.toHexString(System.identityHashCode(contextClassLoader)),
-                            Integer.toHexString(System.identityHashCode(objectClassLoader)));
-        }
         ((PersistenceObject)object)._persistence_set(this.attributeName, value);
     }
 }
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/localization/i18n/TraceLocalizationResource.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/localization/i18n/TraceLocalizationResource.java
index 1f36ee4..48b53a9 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/localization/i18n/TraceLocalizationResource.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/localization/i18n/TraceLocalizationResource.java
@@ -244,8 +244,6 @@ public class TraceLocalizationResource extends ListResourceBundle {
         { "weaver_processing_class", "Class [{0}] registered to be processed by weaver."},
         { "begin_weaving_class", "Begin weaver class transformer processing class [{0}]."},
         { "end_weaving_class", "End weaver class transformer processing class [{0}]."},
-        { "weaving_init_class_writer", "Initializing class writer for [{0}]. Class loaders: context [{1}]."},
-        { "weaving_init_compute_class_writer", "Initializing compute class writer for [{0}]. Class loaders: context [{1}] argument [{2}]."},
         { "transform_missing_class_details", "Missing class details for [{0}]."},
         { "transform_existing_class_bytes", "Using existing class bytes for [{0}]."},
         { "weaved_lazy", "Weaved lazy (ValueHolder indirection) [{0}]."},
@@ -253,13 +251,6 @@ public class TraceLocalizationResource extends ListResourceBundle {
         { "weaved_changetracker", "Weaved change tracking (ChangeTracker) [{0}]."},
         { "weaved_persistenceentity", "Weaved persistence (PersistenceEntity) [{0}]."},
         { "weaved_rest", "Weaved REST [{0}]."},
-        { "class_weaver_add_get_set_add_get", "Adding _persistence_get() method into [{0}]." },
-        { "class_weaver_add_get_set_add_set", "Adding _persistence_set() method into [{0}]." },
-        { "class_weaver_visit_end_do","Visiting the end of the class [{0}]." },
-        { "class_weaver_visit_end_skip","Skipping the end of the class [{0}]." },
-        { "class_weaver_visit_end_internal","Processing internal optimizations [{0}]." },
-        { "weaving_call_persistence_get", "Calling [{0}]._persistence_get. Class loaders: context [{1}], instance [{2}]"},
-        { "weaving_call_persistence_set", "Calling [{0}]._persistence_set. Class loaders: context [{1}], instance [{2}]"},
         { "cmp_init_invoke_predeploy", "JavaSECMPInitializer - predeploying {0}."},
         { "cmp_init_register_transformer", "JavaSECMPInitializer - registering transformer for {0}."},
         { "cmp_init_tempLoader_created", "JavaSECMPInitializer - created temporary ClassLoader: {0}."},
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/logging/StdErrLogger.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/logging/StdErrLogger.java
deleted file mode 100644
index ba91dff..0000000
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/logging/StdErrLogger.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015, 2017 Oracle, IBM Corporation and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *     06/08/2015-2.6 Tomas Kraus
- *       - initial API and implementation.
- *     11/07/2017 - Dalia Abo Sheasha
- *       - 526957 : Split the logging and trace messages
- ******************************************************************************/
-package org.eclipse.persistence.internal.logging;
-
-import java.security.AccessController;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.persistence.internal.localization.LoggingLocalization;
-import org.eclipse.persistence.internal.localization.TraceLocalization;
-import org.eclipse.persistence.internal.security.PrivilegedAccessHelper;
-import org.eclipse.persistence.internal.security.PrivilegedGetSystemProperty;
-import org.eclipse.persistence.logging.AbstractSessionLog;
-import org.eclipse.persistence.logging.SessionLog;
-
-/**
- * INTERNAL:
- * Log to EclipseLink logger and optionally to standard error output.
- * Standard error output logging is enabled by:
- * <ul><li>{@code org.eclipse.persistence.jpa.log.stderr} for all logger categories</li>
- * <li>{@code org.eclipse.persistence.jpa.<category>.log.stderr} for individual logger category</li></ul>
- * Logger API is based on {@link SessionLog}.
- * @since 2.7
- */
-public class StdErrLogger {
-
-    /** Logger. */
-    private static final SessionLog LOGGER = AbstractSessionLog.getLog();
-
-    /** Standard error output logger property name prefix. */
-    private static final String PROPERTY_NAME_PREFIX = "eclipselink.log";
-
-    /** Standard error output logger property name suffix. */
-    private static final String PROPERTY_NAME_SUFFIX = "stderr";
-
-    /** Standard error output logger property name components separator. */
-    private static final char PROPERTY_NAME_SEPARATOR = '.';
-
-    /** {@link String} to separate logging category from message text in standard error output. */
-    private static final String CATEGORY_SEPARATOR = ": ";
-
-    /** {@link String} to prefix stack trace message in standard error output. */
-    private static final String STACK_TRACE_PREFIX = " - ";
-
-    /** Standard error output triggers for specific EclipseLink logging categories. */
-    private static final Map<String, Boolean> logEnabledCategory = initLogEnabledCategory();
-
-    // PERF: Global standard error output trigger to check before getting from Map.
-    /** Global standard error output trigger. EclipseLink logging categories are allowed to be sent to standard error
-     *  output when value is set to {@code true}. No standard error output will be done when value is set
-     *  to {@code false}. */
-    private static final boolean logEnabled = logEnabledCategory != null;
-
-    /**
-     * INTERNAL:
-     * Initialize {@logEnabledCategory} standard error output triggers for specific EclipseLink logging categories.
-     * @return Standard error output triggers {@link Map} for specific EclipseLink logging categories or {@code null}
-     *         if no standard error output was enabled.
-     */
-    private static Map<String, Boolean> initLogEnabledCategory() {
-        final int PropertyExtensionsLength = PROPERTY_NAME_PREFIX.length() + PROPERTY_NAME_SUFFIX.length() + 2;
-        final Map<String, Boolean> logEnabledMap = new HashMap<>(SessionLog.loggerCatagories.length);
-        boolean globalTrigger;
-        if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
-            globalTrigger = Boolean.valueOf(AccessController.doPrivileged(new PrivilegedGetSystemProperty(
-                    PROPERTY_NAME_PREFIX + PROPERTY_NAME_SEPARATOR + PROPERTY_NAME_SUFFIX)));
-        } else {
-            globalTrigger = Boolean.valueOf(System.getProperty(
-                    PROPERTY_NAME_PREFIX + PROPERTY_NAME_SEPARATOR + PROPERTY_NAME_SUFFIX));
-        }
-        boolean enable = globalTrigger;
-        for (final String category : SessionLog.loggerCatagories) {
-            if (globalTrigger) {
-                logEnabledMap.put(category, Boolean.TRUE);
-            } else {
-                StringBuilder propertyKey = new StringBuilder(PropertyExtensionsLength + category.length());
-                propertyKey.append(PROPERTY_NAME_PREFIX);
-                propertyKey.append(PROPERTY_NAME_SEPARATOR);
-                propertyKey.append(category);
-                propertyKey.append(PROPERTY_NAME_SEPARATOR);
-                propertyKey.append(PROPERTY_NAME_SUFFIX);
-                boolean trigger;
-                if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
-                    trigger = Boolean.valueOf(AccessController.doPrivileged(
-                            new PrivilegedGetSystemProperty(propertyKey.toString())));
-                } else {
-                    trigger = Boolean.valueOf(System.getProperty(propertyKey.toString()));
-                }
-                logEnabledMap.put(category, Boolean.valueOf(trigger));
-                enable = enable || trigger;
-            }
-        }
-        if (!enable) {
-            logEnabledMap.clear();
-        }
-        return enable ? logEnabledMap : null;
-    }
-
-    /**
-     * INTERNAL:
-     * Check if a message of the given category would actually be logged to standard error output.
-     * @return Value of {@code true} when a message of the given {@code category} would actually be logged to standard
-     *         error output or {@code false} otherwise.
-     */
-    private static final boolean shouldLogToStdErr(final String category) {
-        final Boolean enabled = logEnabledCategory.get(category);
-        return enabled != null ? enabled.booleanValue() : false;
-    }
-
-    /**
-     * INTERNAL:
-     * Log message to standard error output.
-     * @param category   The EclipseLink logging category.
-     * @param messageKey The {@link TraceLocalizationResource} log message key.
-     * @param arguments  Arguments of the log message.
-     */
-    private static void logStdErr(
-            final String category, final String messageKey, final Object... arguments) {
-        final String message = arguments == null || arguments.length == 0 ?
-                TraceLocalization.buildMessage(messageKey) : TraceLocalization.buildMessage(messageKey, arguments);
-        final int messageLength = message != null ? message.length() : 0;
-        final int categoryLength = category != null ? category.length() + CATEGORY_SEPARATOR.length() : 0;
-        if (categoryLength > 0 || messageLength > 0) {
-            final StringBuilder sb = new StringBuilder(categoryLength + messageLength);
-            if (categoryLength > 0) {
-                sb.append(category);
-                sb.append(CATEGORY_SEPARATOR);
-            }
-            if (messageLength > 0) {
-                sb.append(message);
-            }
-            System.err.println(sb.toString());
-        }
-    }
-
-    /**
-     * INTERNAL:
-     * Log message to standard error output.
-     * @param category  The EclipseLink logging category.
-     * @param throwable {@link Throwable} to be logged.
-     */
-    private static void logThrowableStdErr(final String category, final Throwable throwable) {
-        final int categoryLength = category != null ? category.length() + CATEGORY_SEPARATOR.length() : 0;
-        for (StackTraceElement ste : throwable.getStackTrace()) {
-            final String message = ste.toString();
-            StringBuilder sb = new StringBuilder(categoryLength + STACK_TRACE_PREFIX.length() + message.length());
-            if (categoryLength > 0) {
-                sb.append(category);
-                sb.append(CATEGORY_SEPARATOR);
-            }
-            sb.append(STACK_TRACE_PREFIX);
-            sb.append(message);
-            System.err.println(sb.toString());
-        }
-    }
-
-    /**
-     * INTERNAL:
-     * Check if a message of the given {@code category} and {@code level} would actually be logged by EclipseLink logger
-     * or to standard error output.
-     * @param level    The log request level value.
-     * @param category The EclipseLink logging category.
-     * @return Value of {@code true} if message  will be logged or {@code false} otherwise.
-     */
-    public static final boolean shouldLog(final int level, final String category) {
-        return (logEnabled && shouldLogToStdErr(category)) || LOGGER.shouldLog(level, category);
-    }
-
-    /**
-     * INTERNAL:
-     * Log message with no arguments to EclipseLink logger and standard error output.
-     * @param level      The log request level value.
-     * @param category   The EclipseLink logging category.
-     * @param messageKey The {@link TraceLocalizationResource} log message key.
-     */
-    public static final void log(final int level, final String category, final String messageKey) {
-        LOGGER.log(level, category, messageKey, null);
-        if (logEnabled && shouldLogToStdErr(category)) {
-            logStdErr(category, messageKey);
-        }
-    }
-
-    /**
-     * INTERNAL:
-     * Log message with arguments array to EclipseLink logger and standard error output.
-     * @param level      The log request level value.
-     * @param category   The EclipseLink logging category.
-     * @param messageKey {@link TraceLocalizationResource} message key.
-     * @param arguments  Arguments of the log message.
-     */
-    public static final void log(
-            final int level, final String category, final String messageKey, final Object... arguments) {
-        LOGGER.log(level, category, messageKey, arguments);
-        if (logEnabled && shouldLogToStdErr(category)) {
-            logStdErr(category, messageKey, arguments);
-        }
-    }
-
-    /**
-     * INTERNAL:
-     * Log {@link Throwable} to EclipseLink logger and standard error output.
-     * @param level     The log request level value.
-     * @param category  The EclipseLink logging category.
-     * @param throwable {@link Throwable} to be logged.
-     */
-    public static final void logThrowable(final int level, final String category, final Throwable throwable) {
-        LOGGER.logThrowable(level, category, throwable);
-        if (logEnabled && shouldLogToStdErr(category)) {
-            logThrowableStdErr(category, throwable);
-        }
-    }
-
-}
diff --git a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/weaving/ClassWeaver.java b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/weaving/ClassWeaver.java
index 5cc6f83..a387eb4 100644
--- a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/weaving/ClassWeaver.java
+++ b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/weaving/ClassWeaver.java
@@ -28,8 +28,6 @@
 import org.eclipse.persistence.internal.libraries.asm.MethodVisitor;
 import org.eclipse.persistence.internal.libraries.asm.Opcodes;
 import org.eclipse.persistence.internal.libraries.asm.Type;
-import org.eclipse.persistence.internal.logging.StdErrLogger;
-import org.eclipse.persistence.logging.SessionLog;
 
 /**
  * INTERNAL: Weaves classes to allow them to support EclipseLink indirection.
@@ -912,12 +910,7 @@ public void addPersistenceNew(ClassDetails classDetails) {
      * "city") { this.city = (String)city; } }
      */
     public void addPersistenceGetSet(ClassDetails classDetails) {
-        // PERF: Is finest logging turned on?
-        final boolean shouldLogFinest = StdErrLogger.shouldLog(SessionLog.FINEST, SessionLog.WEAVER);
         // create the _persistence_get() method
-        if (shouldLogFinest) {
-            StdErrLogger.log(SessionLog.FINEST, SessionLog.WEAVER, "class_weaver_add_get_set_add_get", classDetails.getClassName());
-        }
         MethodVisitor cv_get = cv.visitMethod(ACC_PUBLIC, "_persistence_get", "(Ljava/lang/String;)Ljava/lang/Object;", null, null);
 
         Label label = null;
@@ -962,9 +955,6 @@ public void addPersistenceGetSet(ClassDetails classDetails) {
         cv_get.visitMaxs(0, 0);
 
         // create the _persistence_set() method
-        if (shouldLogFinest) {
-            StdErrLogger.log(SessionLog.FINEST, SessionLog.WEAVER, "class_weaver_add_get_set_add_set", classDetails.getClassName());
-        }
         MethodVisitor cv_set = cv.visitMethod(ACC_PUBLIC, "_persistence_set", "(Ljava/lang/String;Ljava/lang/Object;)V", null, null);
 
         label = null;
@@ -1365,13 +1355,7 @@ public MethodVisitor visitMethod(int access, String methodName, String desc, Str
      */
     @Override
     public void visitEnd() {
-        // PERF: Is finest logging turned on?
-        final boolean shouldLogFinest = StdErrLogger.shouldLog(SessionLog.FINEST, SessionLog.WEAVER);
         if (!alreadyWeaved) {
-            if (shouldLogFinest) {
-                StdErrLogger.log(
-                        SessionLog.FINEST, SessionLog.WEAVER, "class_weaver_visit_end_do", classDetails.getClassName());
-            }
             if (this.classDetails.shouldWeaveInternal()) {
 
                 // Add a persistence and shallow clone method.
@@ -1450,8 +1434,6 @@ public void visitEnd() {
                     addFetchGroupMethods(this.classDetails);
                 }
             }
-        } else if (shouldLogFinest) {
-            StdErrLogger.log(SessionLog.FINEST, SessionLog.WEAVER, "class_weaver_visit_end_skip", classDetails.getClassName());
         }
         if (classDetails.shouldWeaveREST() && classDetails.getSuperClassDetails() == null) {
             weavedRest = true;
diff --git a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/weaving/PersistenceWeaver.java b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/weaving/PersistenceWeaver.java
index 5f3f9b4..466970d 100644
--- a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/weaving/PersistenceWeaver.java
+++ b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/weaving/PersistenceWeaver.java
@@ -29,9 +29,9 @@
 import org.eclipse.persistence.internal.libraries.asm.ClassVisitor;
 import org.eclipse.persistence.internal.libraries.asm.ClassWriter;
 import org.eclipse.persistence.internal.libraries.asm.commons.SerialVersionUIDAdder;
-import org.eclipse.persistence.internal.logging.StdErrLogger;
 import org.eclipse.persistence.internal.security.PrivilegedAccessHelper;
 import org.eclipse.persistence.internal.security.PrivilegedGetClassLoaderFromCurrentThread;
+import org.eclipse.persistence.logging.AbstractSessionLog;
 import org.eclipse.persistence.logging.SessionLog;
 import org.eclipse.persistence.sessions.Session;
 
@@ -102,8 +102,9 @@ public Map<String, ClassDetails> getClassDetailsMap() {
     public byte[] transform(final ClassLoader loader, final String className,
             final Class classBeingRedefined, final ProtectionDomain protectionDomain,
             final byte[] classfileBuffer) throws IllegalClassFormatException {
-        // PERF: Is finest logging turned on?
-        final boolean shouldLogFinest = StdErrLogger.shouldLog(SessionLog.FINEST, SessionLog.WEAVER);
+        final SessionLog log = AbstractSessionLog.getLog();
+        // PERF: Is finest logging on weaving turned on?
+        final boolean shouldLogFinest = log.shouldLog(SessionLog.FINEST, SessionLog.WEAVER);
         final Map classDetailsMap = this.classDetailsMap;
         // Check if cleared already.
         if (classDetailsMap == null) {
@@ -120,7 +121,7 @@ public Map<String, ClassDetails> getClassDetailsMap() {
 
             if (classDetails != null) {
                 if (shouldLogFinest) {
-                    StdErrLogger.log(SessionLog.FINEST, SessionLog.WEAVER, "begin_weaving_class", className);
+                    log.log(SessionLog.FINEST, SessionLog.WEAVER, "begin_weaving_class", className);
                 }
                 final ClassReader classReader = new ClassReader(classfileBuffer);
                 final String reflectiveIntrospectionProperty =
@@ -130,31 +131,10 @@ public Map<String, ClassDetails> getClassDetailsMap() {
                         : new ComputeClassWriter(loader, ClassWriter.COMPUTE_FRAMES);
                 final ClassWeaver classWeaver = new ClassWeaver(classWriter, classDetails);
                 final ClassVisitor sv = new SerialVersionUIDAdder(classWeaver);
-                if (shouldLogFinest) {
-                    ClassLoader contextClassLoader;
-                    if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
-                        try {
-                            contextClassLoader = AccessController.doPrivileged(
-                                    new PrivilegedGetClassLoaderFromCurrentThread());
-                        } catch (PrivilegedActionException ex) {
-                            throw (RuntimeException) ex.getCause();
-                        }
-                    } else {
-                        contextClassLoader = Thread.currentThread().getContextClassLoader();
-                    }
-                    if (reflectiveIntrospectionProperty != null) {
-                        StdErrLogger.log(SessionLog.FINEST, SessionLog.WEAVER, "weaving_init_class_writer",
-                                className, Integer.toHexString(System.identityHashCode(contextClassLoader)));
-                    } else {
-                        StdErrLogger.log(SessionLog.FINEST, SessionLog.WEAVER, "weaving_init_compute_class_writer",
-                                className, Integer.toHexString(System.identityHashCode(contextClassLoader)),
-                                loader != null ? Integer.toHexString(System.identityHashCode(loader)) : "null");
-                    }
-                }
                 classReader.accept(sv, 0);
                 if (classWeaver.alreadyWeaved) {
                     if (shouldLogFinest) {
-                        StdErrLogger.log(SessionLog.FINEST, SessionLog.WEAVER, "end_weaving_class", className);
+                        log.log(SessionLog.FINEST, SessionLog.WEAVER, "end_weaving_class", className);
                     }
                     return null;
                 }
@@ -169,45 +149,43 @@ public Map<String, ClassDetails> getClassDetailsMap() {
                     // PERF: Don't execute this set of if statements with logging turned off.
                     if (shouldLogFinest) {
                         if (classWeaver.weavedPersistenceEntity) {
-                            StdErrLogger.log(
-                                    SessionLog.FINEST, SessionLog.WEAVER, "weaved_persistenceentity", className);
+                            log.log(SessionLog.FINEST, SessionLog.WEAVER, "weaved_persistenceentity", className);
                         }
                         if (classWeaver.weavedChangeTracker) {
-                            StdErrLogger.log(SessionLog.FINEST, SessionLog.WEAVER, "weaved_changetracker", className);
+                            log.log(SessionLog.FINEST, SessionLog.WEAVER, "weaved_changetracker", className);
                         }
                         if (classWeaver.weavedLazy) {
-                            StdErrLogger.log(SessionLog.FINEST, SessionLog.WEAVER, "weaved_lazy", className);
+                            log.log(SessionLog.FINEST, SessionLog.WEAVER, "weaved_lazy", className);
                         }
                         if (classWeaver.weavedFetchGroups) {
-                            StdErrLogger.log(SessionLog.FINEST, SessionLog.WEAVER, "weaved_fetchgroups", className);
+                            log.log(SessionLog.FINEST, SessionLog.WEAVER, "weaved_fetchgroups", className);
                         }
                         if (classWeaver.weavedRest) {
-                            StdErrLogger.log(SessionLog.FINEST, SessionLog.WEAVER, "weaved_rest", className);
+                            log.log(SessionLog.FINEST, SessionLog.WEAVER, "weaved_rest", className);
                         }
-                        StdErrLogger.log(SessionLog.FINEST, SessionLog.WEAVER, "end_weaving_class", className);
+                        log.log(SessionLog.FINEST, SessionLog.WEAVER, "end_weaving_class", className);
                     }
                     return bytes;
                 }
                 if (shouldLogFinest) {
-                    StdErrLogger.log(SessionLog.FINEST, SessionLog.WEAVER, "end_weaving_class", className);
+                    log.log(SessionLog.FINEST, SessionLog.WEAVER, "end_weaving_class", className);
                 }
             } else {
                 if (shouldLogFinest) {
-                    StdErrLogger.log(
-                            SessionLog.FINEST, SessionLog.WEAVER, "transform_missing_class_details", className);
+                    log.log(SessionLog.FINEST, SessionLog.WEAVER, "transform_missing_class_details", className);
                 }
             }
         } catch (Throwable exception) {
-            if (StdErrLogger.shouldLog(SessionLog.WARNING, SessionLog.WEAVER)) {
-                StdErrLogger.log(SessionLog.WARNING, SessionLog.WEAVER,
+            if (log.shouldLog(SessionLog.WARNING, SessionLog.WEAVER)) {
+                log.log(SessionLog.WARNING, SessionLog.WEAVER,
                         "exception_while_weaving", new Object[] {className, exception.getLocalizedMessage()});
                 if (shouldLogFinest) {
-                    StdErrLogger.logThrowable(SessionLog.FINEST, SessionLog.WEAVER, exception);
+                    log.logThrowable(SessionLog.FINEST, SessionLog.WEAVER, exception);
                 }
             }
         }
         if (shouldLogFinest) {
-            StdErrLogger.log(SessionLog.FINEST, SessionLog.WEAVER, "transform_existing_class_bytes", className);
+            log.log(SessionLog.FINEST, SessionLog.WEAVER, "transform_existing_class_bytes", className);
         }
         // Returning null means 'use existing class bytes'.
         return null;