commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1512985 - in /commons/sandbox/weaver/trunk: modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/ processor/src/main/java/org/apache/commons/weaver/ processor/src/main/java/org/apache/commons/weaver/model/
Date Sun, 11 Aug 2013 18:34:56 GMT
Author: mbenson
Date: Sun Aug 11 18:34:56 2013
New Revision: 1512985

URL: http://svn.apache.org/r1512985
Log:
use env classLoader, remove classpath

Modified:
    commons/sandbox/weaver/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/BlueprintingVisitor.java
    commons/sandbox/weaver/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
    commons/sandbox/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/CleanProcessor.java
    commons/sandbox/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/WeaveProcessor.java
    commons/sandbox/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/model/WeaveEnvironment.java

Modified: commons/sandbox/weaver/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/BlueprintingVisitor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/weaver/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/BlueprintingVisitor.java?rev=1512985&r1=1512984&r2=1512985&view=diff
==============================================================================
--- commons/sandbox/weaver/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/BlueprintingVisitor.java
(original)
+++ commons/sandbox/weaver/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/BlueprintingVisitor.java
Sun Aug 11 18:34:56 2013
@@ -297,7 +297,7 @@ class BlueprintingVisitor extends Privil
         }
 
         private Class<?> load(Type t) throws ClassNotFoundException {
-            return privilizer().classLoader.loadClass(t.getClassName());
+            return privilizer().env.classLoader.loadClass(t.getClassName());
         }
     }
 

Modified: commons/sandbox/weaver/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/weaver/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java?rev=1512985&r1=1512984&r2=1512985&view=diff
==============================================================================
--- commons/sandbox/weaver/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
(original)
+++ commons/sandbox/weaver/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
Sun Aug 11 18:34:56 2013
@@ -23,9 +23,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintWriter;
 import java.io.StringWriter;
-import java.net.URLClassLoader;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Set;
 
 import org.apache.commons.io.FileUtils;
@@ -34,10 +32,6 @@ import org.apache.commons.lang3.BooleanU
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.Validate;
 import org.apache.commons.weaver.model.WeaveEnvironment;
-import org.apache.commons.weaver.privilizer.AccessLevel;
-import org.apache.commons.weaver.privilizer.Policy;
-import org.apache.commons.weaver.privilizer.Privilizing;
-import org.apache.commons.weaver.utils.URLArray;
 import org.apache.xbean.finder.archive.FileArchive;
 import org.objectweb.asm.ClassReader;
 import org.objectweb.asm.ClassVisitor;
@@ -110,21 +104,16 @@ public class Privilizer {
 
     final WeaveEnvironment env;
     final AccessLevel accessLevel;
-    final ClassLoader classLoader;
     final FileArchive fileArchive;
     final Policy policy;
     final boolean verify;
 
-    private final List<String> classpath;
-
     public Privilizer(WeaveEnvironment env) {
         super();
         this.env = env;
         this.policy = Policy.parse(env.config.getProperty(CONFIG_POLICY));
         this.accessLevel = AccessLevel.parse(env.config.getProperty(CONFIG_ACCESS_LEVEL));
-        this.classpath = env.classpath;
-        classLoader = new URLClassLoader(URLArray.fromPaths(env.classpath));
-        fileArchive = new FileArchive(classLoader, env.target);
+        fileArchive = new FileArchive(env.classLoader, env.target);
         verify = BooleanUtils.toBoolean(env.config.getProperty(CONFIG_VERIFY));
     }
 
@@ -200,22 +189,9 @@ public class Privilizer {
     void verify(final String className, final byte[] bytecode) {
         final ClassReader reader = new ClassReader(bytecode);
 
-        // use a new classloader that is always up to date:
-        final ClassLoader verifyClassLoader = new URLClassLoader(URLArray.fromPaths(classpath))
{
-            @Override
-            protected Class<?> findClass(String name) throws ClassNotFoundException
{
-                if (className.equals(name)) {
-                    final Class<?> result = defineClass(className, bytecode, 0, bytecode.length);
-                    resolveClass(result);
-                    return result;
-                }
-                return super.findClass(name);
-            }
-        };
-
         env.debug("Verifying bytecode for class %s", className);
         final StringWriter w = new StringWriter();
-        CheckClassAdapter.verify(reader, verifyClassLoader, false, new PrintWriter(w));
+        CheckClassAdapter.verify(reader, env.classLoader, false, new PrintWriter(w));
         final String error = w.toString();
         if (!error.isEmpty()) {
             env.error(error);

Modified: commons/sandbox/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/CleanProcessor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/CleanProcessor.java?rev=1512985&r1=1512984&r2=1512985&view=diff
==============================================================================
--- commons/sandbox/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/CleanProcessor.java
(original)
+++ commons/sandbox/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/CleanProcessor.java
Sun Aug 11 18:34:56 2013
@@ -85,8 +85,7 @@ public class CleanProcessor {
         final Finder finder = new Finder(new FileArchive(classLoader, target));
         for (Cleaner cleaner : CLEANERS) {
             final WeaveEnvironment env =
-                new WeaveEnvironment(classpath, target, classLoader, configuration, Logger.getLogger(cleaner.getClass()
-                    .getName()));
+                new WeaveEnvironment(target, classLoader, configuration, Logger.getLogger(cleaner.getClass().getName()));
             cleaner.clean(env, finder);
         }
     }

Modified: commons/sandbox/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/WeaveProcessor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/WeaveProcessor.java?rev=1512985&r1=1512984&r2=1512985&view=diff
==============================================================================
--- commons/sandbox/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/WeaveProcessor.java
(original)
+++ commons/sandbox/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/WeaveProcessor.java
Sun Aug 11 18:34:56 2013
@@ -86,8 +86,7 @@ public class WeaveProcessor {
         final Finder finder = new Finder(new FileArchive(classLoader, target));
         for (Weaver weaver : WEAVERS) {
             final WeaveEnvironment env =
-                new WeaveEnvironment(classpath, target, classLoader, configuration, Logger.getLogger(weaver.getClass()
-                    .getName()));
+                new WeaveEnvironment(target, classLoader, configuration, Logger.getLogger(weaver.getClass().getName()));
             weaver.process(env, finder);
         }
     }

Modified: commons/sandbox/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/model/WeaveEnvironment.java
URL: http://svn.apache.org/viewvc/commons/sandbox/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/model/WeaveEnvironment.java?rev=1512985&r1=1512984&r2=1512985&view=diff
==============================================================================
--- commons/sandbox/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/model/WeaveEnvironment.java
(original)
+++ commons/sandbox/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/model/WeaveEnvironment.java
Sun Aug 11 18:34:56 2013
@@ -19,8 +19,6 @@
 package org.apache.commons.weaver.model;
 
 import java.io.File;
-import java.util.Collections;
-import java.util.List;
 import java.util.Properties;
 import java.util.logging.Logger;
 
@@ -32,10 +30,6 @@ import org.apache.commons.weaver.spi.Wea
  * Encapsulates the environment in which a {@link Weaver} or {@link Cleaner} must operate.
  */
 public class WeaveEnvironment {
-    /**
-     * Classpath.
-     */
-    public final List<String> classpath;
 
     /**
      * Target where weavable classes reside.
@@ -57,16 +51,13 @@ public class WeaveEnvironment {
 
     /**
      * Create a new {@link WeaveEnvironment}.
-     * 
-     * @param classpath
      * @param target
      * @param classLoader
      * @param config
      * @param log
      */
-    public WeaveEnvironment(List<String> classpath, File target, ClassLoader classLoader,
Properties config, Logger log) {
+    public WeaveEnvironment(File target, ClassLoader classLoader, Properties config, Logger
log) {
         super();
-        this.classpath = Collections.unmodifiableList(Validate.notNull(classpath, "classpath"));
         this.target = Validate.notNull(target, "target");
         this.classLoader = classLoader;
         this.config = (Properties) Validate.notNull(config, "config").clone();



Mime
View raw message