You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mb...@apache.org on 2018/04/29 19:40:51 UTC

[commons-weaver] branch master updated (9329b14 -> 52c0f98)

This is an automated email from the ASF dual-hosted git repository.

mbenson pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-weaver.git.


    from 9329b14  Update commons-parent from 42 to 43.
     new 901ba1a  Java 8; assorted minor refactorings
     new 5f50c12  remove obsolete dependencies
     new ad16043  centralize ASM versions
     new 11f857a  upgrade commons-lang3
     new 3dd506f  remove shading for obsolete deps
     new 08ac94d  upgrade japicmp
     new 9fea2ca  upgrade xbean-finder
     new c419b33  small cleanups
     new 1c6c4e3  small cleanups
     new b3b4583  upgrade modules to ASM 6.1
     new 232f479  clone from ClassWriter#getCommonSuperClass
     new 6569dd1  blueprint method references; reject blueprint methods that access inaccessible classes/methods/ctors (other than other methods also being imported
     new 52c0f98  upgrade to ASM API v6

The 13 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 BUILDING.txt                                       |   2 +-
 LICENSE-asm5.1.txt => LICENSE-asm6.1.txt           |   0
 ant/pom.xml                                        |  25 +-
 .../commons/weaver/ant/AbstractWeaverTask.java     |   1 -
 .../org/apache/commons/weaver/ant/CleanTask.java   |   4 +-
 .../org/apache/commons/weaver/ant/WeaveTask.java   |   4 +-
 .../apache/commons/weaver/ant/WeaverSettings.java  |   2 -
 maven-plugin/pom.xml                               |   2 +-
 .../commons/weaver/maven/AbstractCWMojo.java       |  12 +-
 .../commons/weaver/maven/AbstractPrepareMojo.java  |   4 +-
 .../commons/weaver/maven/AbstractWeaveMojo.java    |   4 +-
 .../maven/JavaLoggingToMojoLoggingRedirector.java  |  21 +-
 .../apache/commons/weaver/maven/PrepareMojo.java   |   1 -
 .../commons/weaver/maven/TestPrepareMojo.java      |   1 -
 .../apache/commons/weaver/maven/TestWeaveMojo.java |   1 -
 .../org/apache/commons/weaver/maven/WeaveMojo.java |   1 -
 modules/normalizer/pom.xml                         |  50 +---
 .../commons/weaver/normalizer/Normalizer.java      |  92 ++-----
 .../weaver/normalizer/NormalizerWeaver.java        |   1 -
 .../apache/commons/weaver/normalizer/Utils.java    |   9 +-
 modules/privilizer/weaver/pom.xml                  | 174 +++++-------
 modules/privilizer/weaver/src/it/sample/pom.xml    |   7 +
 ...s.java => MethodReferencesUsingBlueprints.java} |  29 +-
 ...va => MethodReferencesUsingBlueprintsTest.java} |  29 +-
 .../commons/weaver/privilizer/ActionGenerator.java |  10 +-
 .../weaver/privilizer/BlueprintingVisitor.java     | 303 ++++++++++++--------
 .../apache/commons/weaver/privilizer/Field.java    |  12 +-
 .../commons/weaver/privilizer/FieldAccess.java     |   1 -
 .../privilizer/InlineNestedPrivilegedCalls.java    |   7 +-
 .../apache/commons/weaver/privilizer/Policy.java   |   1 -
 .../commons/weaver/privilizer/Privilizer.java      | 106 +++----
 .../weaver/privilizer/PrivilizerCleaner.java       |  14 +-
 .../weaver/privilizer/PrivilizerWeaver.java        |   2 +-
 .../weaver/privilizer/PrivilizingVisitor.java      |  15 +-
 parent/pom.xml                                     |  16 +-
 pom.xml                                            |  13 +-
 processor/pom.xml                                  |  31 ++-
 .../org/apache/commons/weaver/CleanProcessor.java  |   2 +-
 .../java/org/apache/commons/weaver/Finder.java     | 304 +++++++--------------
 .../java/org/apache/commons/weaver/Inflater.java   |  88 +++---
 .../org/apache/commons/weaver/ProcessorBase.java   |   4 +-
 .../org/apache/commons/weaver/WeaveProcessor.java  |   2 +-
 .../apache/commons/weaver/model/ScanRequest.java   |   4 +-
 .../apache/commons/weaver/model/ScanResult.java    |   9 +-
 .../org/apache/commons/weaver/model/Weavable.java  |   2 +-
 .../apache/commons/weaver/model/WeavableClass.java |  39 +--
 .../commons/weaver/model/WeavableConstructor.java  |   1 -
 .../weaver/model/WeavableConstructorParameter.java |   1 -
 .../commons/weaver/model/WeavableExecutable.java   |   3 +-
 .../commons/weaver/model/WeavableMethod.java       |   2 +-
 .../weaver/model/WeavableMethodParameter.java      |   1 -
 .../commons/weaver/model/WeavablePackage.java      |   6 +-
 .../commons/weaver/model/WeavableParameter.java    |   1 -
 .../commons/weaver/model/WeaveEnvironment.java     |  37 +--
 .../apache/commons/weaver/model/WeaveInterest.java |  20 +-
 .../java/org/apache/commons/weaver/utils/Args.java |   1 -
 .../org/apache/commons/weaver/utils/Providers.java |  33 +--
 .../org/apache/commons/weaver/utils/URLArray.java  |  60 ++--
 58 files changed, 705 insertions(+), 922 deletions(-)
 mode change 120000 => 100644 BUILDING.txt
 rename LICENSE-asm5.1.txt => LICENSE-asm6.1.txt (100%)
 copy modules/privilizer/weaver/src/it/sample/src/main/java/org/apache/commons/weaver/privilizer/example/{UsingBlueprints.java => MethodReferencesUsingBlueprints.java} (62%)
 copy modules/privilizer/weaver/src/it/sample/src/test/java/org/apache/commons/weaver/privilizer/example/{UsingBlueprintsTest.java => MethodReferencesUsingBlueprintsTest.java} (59%)

-- 
To stop receiving notification emails like this one, please contact
mbenson@apache.org.

[commons-weaver] 12/13: blueprint method references; reject blueprint methods that access inaccessible classes/methods/ctors (other than other methods also being imported

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mbenson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-weaver.git

commit 6569dd18ec5c9a02cb3308d1552de7d0c5ed3505
Author: Matt Benson <mb...@apache.org>
AuthorDate: Tue Apr 24 17:16:02 2018 -0500

    blueprint method references; reject blueprint methods that access inaccessible classes/methods/ctors (other than other methods also being imported
---
 modules/privilizer/weaver/src/it/sample/pom.xml    |   7 +
 .../example/MethodReferencesUsingBlueprints.java   |  67 ++++++
 .../MethodReferencesUsingBlueprintsTest.java       |  81 +++++++
 .../weaver/privilizer/BlueprintingVisitor.java     | 256 ++++++++++++++-------
 .../commons/weaver/privilizer/Privilizer.java      |  44 ++--
 5 files changed, 346 insertions(+), 109 deletions(-)

diff --git a/modules/privilizer/weaver/src/it/sample/pom.xml b/modules/privilizer/weaver/src/it/sample/pom.xml
index e0c2d20..c1927c4 100755
--- a/modules/privilizer/weaver/src/it/sample/pom.xml
+++ b/modules/privilizer/weaver/src/it/sample/pom.xml
@@ -54,6 +54,13 @@ under the License.
   <build>
     <plugins>
       <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.8</source>
+          <target>1.8</target>
+        </configuration>
+      </plugin>
+      <plugin>
         <groupId>@project.groupId@</groupId>
         <artifactId>commons-weaver-maven-plugin</artifactId>
         <version>@project.version@</version>
diff --git a/modules/privilizer/weaver/src/it/sample/src/main/java/org/apache/commons/weaver/privilizer/example/MethodReferencesUsingBlueprints.java b/modules/privilizer/weaver/src/it/sample/src/main/java/org/apache/commons/weaver/privilizer/example/MethodReferencesUsingBlueprints.java
new file mode 100644
index 0000000..3e696be
--- /dev/null
+++ b/modules/privilizer/weaver/src/it/sample/src/main/java/org/apache/commons/weaver/privilizer/example/MethodReferencesUsingBlueprints.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.weaver.privilizer.example;
+
+import java.util.function.BiFunction;
+import java.util.function.BinaryOperator;
+import java.util.function.IntSupplier;
+import java.util.function.Supplier;
+import java.util.function.UnaryOperator;
+
+import org.apache.commons.weaver.privilizer.Privilizing;
+import org.apache.commons.weaver.privilizer.Privilizing.CallTo;
+
+@Privilizing({ @CallTo(Utils.class), @CallTo(value = Utils.More.class, methods = "getProperty") })
+public class MethodReferencesUsingBlueprints {
+
+    public String utilsReadPublicConstant() {
+        final Supplier<String> s = Utils::readPublicConstant;
+        return s.get();
+    }
+
+    public int utilsReadPrivateField() {
+        final IntSupplier s = Utils::readPrivateField;
+        return s.getAsInt();
+    }
+
+    public String utilsGetProperty() {
+        final Supplier<String> s = Utils::getProperty;
+        return s.get();
+    }
+
+    public String utilsGetProperty(int i, String key) {
+        final BiFunction<Integer, String, String> f = Utils::getProperty;
+        return f.apply(i, key);
+    }
+
+    public String utilsGetProperty(String key) {
+        final UnaryOperator<String> o = Utils::getProperty;
+        return o.apply(key);
+    }
+
+    public String moreGetProperty() {
+        final Supplier<String> s = Utils.More::getProperty;
+        return s.get();
+    }
+
+    public String moreGetTopStackElementClassName() {
+        final Supplier<String> s = Utils.More::getTopStackElementClassName;
+        return s.get();
+    }
+}
diff --git a/modules/privilizer/weaver/src/it/sample/src/test/java/org/apache/commons/weaver/privilizer/example/MethodReferencesUsingBlueprintsTest.java b/modules/privilizer/weaver/src/it/sample/src/test/java/org/apache/commons/weaver/privilizer/example/MethodReferencesUsingBlueprintsTest.java
new file mode 100644
index 0000000..1fb59d6
--- /dev/null
+++ b/modules/privilizer/weaver/src/it/sample/src/test/java/org/apache/commons/weaver/privilizer/example/MethodReferencesUsingBlueprintsTest.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.weaver.privilizer.example;
+
+import static org.junit.Assume.assumeTrue;
+import static org.junit.Assert.assertEquals;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class MethodReferencesUsingBlueprintsTest {
+
+    private MethodReferencesUsingBlueprints methodReferencesUsingBlueprints;
+
+    @Before
+    public void setUp() throws Exception {
+        Setup.setProperty("foo", "foo-value");
+        Setup.setProperty("bar", "bar-value");
+        Setup.setProperty("baz", "baz-value");
+        methodReferencesUsingBlueprints = new MethodReferencesUsingBlueprints();
+    }
+
+    @Test
+    public void testUtilsReadPublicConstant() {
+        assertEquals(Utils.FOO, methodReferencesUsingBlueprints.utilsReadPublicConstant());
+    }
+
+    @Test
+    public void testUtilsReadPrivateField() {
+        assertEquals(999, methodReferencesUsingBlueprints.utilsReadPrivateField());
+    }
+
+    @Test
+    public void testUtilsGetProperty() {
+        assertEquals("foo-value", methodReferencesUsingBlueprints.utilsGetProperty());
+    }
+
+    @Test
+    public void testUtilsGetProperty_String() {
+        assertEquals("foo-value", methodReferencesUsingBlueprints.utilsGetProperty("foo"));
+        assertEquals("bar-value", methodReferencesUsingBlueprints.utilsGetProperty("bar"));
+        assertEquals("baz-value", methodReferencesUsingBlueprints.utilsGetProperty("baz"));
+    }
+
+    @Test
+    public void testUtilsGetProperty_int_String() {
+        assertEquals("foo-value", methodReferencesUsingBlueprints.utilsGetProperty(2, "foo"));
+        assertEquals("bar-value", methodReferencesUsingBlueprints.utilsGetProperty(2, "bar"));
+        assertEquals("baz-value", methodReferencesUsingBlueprints.utilsGetProperty(2, "baz"));
+    }
+
+    @Test
+    public void testMoreGetProperty() {
+        assertEquals("bar-value", methodReferencesUsingBlueprints.moreGetProperty());
+    }
+
+    @Test
+    public void testMoreGetTopStackElementClassName() {
+        assumeTrue(StringUtils.containsIgnoreCase(SystemUtils.JAVA_VENDOR, "oracle"));
+        assertEquals(Utils.More.class.getName(), methodReferencesUsingBlueprints.moreGetTopStackElementClassName());
+    }
+}
diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/BlueprintingVisitor.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/BlueprintingVisitor.java
index b306a39..e6c6226 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/BlueprintingVisitor.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/BlueprintingVisitor.java
@@ -19,25 +19,29 @@
 package org.apache.commons.weaver.privilizer;
 
 import java.io.InputStream;
+import java.lang.invoke.LambdaMetafactory;
 import java.lang.reflect.Modifier;
-import java.util.ArrayDeque;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.BitSet;
-import java.util.Deque;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.Validate;
-import org.apache.commons.lang3.mutable.MutableObject;
 import org.apache.commons.lang3.tuple.Pair;
 import org.objectweb.asm.ClassReader;
 import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.Handle;
 import org.objectweb.asm.Label;
 import org.objectweb.asm.MethodVisitor;
 import org.objectweb.asm.Opcodes;
@@ -46,19 +50,40 @@ import org.objectweb.asm.commons.AdviceAdapter;
 import org.objectweb.asm.commons.GeneratorAdapter;
 import org.objectweb.asm.commons.Method;
 import org.objectweb.asm.tree.ClassNode;
+import org.objectweb.asm.tree.FieldNode;
 import org.objectweb.asm.tree.MethodNode;
 
 /**
  * {@link ClassVisitor} to import so-called "blueprint methods".
  */
 class BlueprintingVisitor extends Privilizer.PrivilizerClassVisitor {
+    static class TypeInfo {
+        final int access;
+        final String superName;
+        final Map<String, FieldNode> fields;
+        final Map<Method, MethodNode> methods;
+
+        TypeInfo(int access, String superName, Map<String, FieldNode> fields, Map<Method, MethodNode> methods) {
+            super();
+            this.access = access;
+            this.superName = superName;
+            this.fields = fields;
+            this.methods = methods;
+        }
+    }
+
+    private static final Type LAMBDA_METAFACTORY = Type.getType(LambdaMetafactory.class);
+
+    private static Pair<Type, Method> methodKey(String owner, String name, String desc) {
+        return Pair.of(Type.getObjectType(owner), new Method(name, desc));
+    }
 
     private final Set<Type> blueprintTypes = new HashSet<>();
     private final Map<Pair<Type, Method>, MethodNode> blueprintRegistry = new HashMap<>();
 
     private final Map<Pair<Type, Method>, String> importedMethods = new HashMap<>();
 
-    private final Map<Type, Map<Method, MethodNode>> methodCache = new HashMap<>();
+    private final Map<Type, TypeInfo> typeInfoCache = new HashMap<>();
     private final Map<Pair<Type, String>, FieldAccess> fieldAccessMap = new HashMap<>();
 
     private final ClassVisitor nextVisitor;
@@ -79,46 +104,28 @@ class BlueprintingVisitor extends Privilizer.PrivilizerClassVisitor {
         for (final Privilizing.CallTo callTo : config.value()) {
             final Type blueprintType = Type.getType(callTo.value());
             blueprintTypes.add(blueprintType);
-            for (final Map.Entry<Method, MethodNode> entry : getMethods(blueprintType).entrySet()) {
-                boolean found = false;
-                if (callTo.methods().length == 0) {
-                    found = true;
-                } else {
-                    for (final String name : callTo.methods()) {
-                        if (entry.getKey().getName().equals(name)) {
-                            found = true;
-                            break;
-                        }
-                    }
-                }
-                if (found) {
-                    blueprintRegistry.put(Pair.of(blueprintType, entry.getKey()), entry.getValue());
-                }
-            }
-        }
-    }
 
-    private Map<Method, MethodNode> getMethods(final Type type) {
-        if (methodCache.containsKey(type)) {
-            return methodCache.get(type);
+            final Set<String> methodNames = new HashSet<>(Arrays.asList(callTo.methods()));
+
+            typeInfo(blueprintType).methods.entrySet().stream()
+                .filter(e -> methodNames.isEmpty() || methodNames.contains(e.getKey().getName()))
+                .forEach(e -> blueprintRegistry.put(Pair.of(blueprintType, e.getKey()), e.getValue()));
         }
-        final ClassNode classNode = read(type.getClassName());
-        final Map<Method, MethodNode> result = new HashMap<>();
+    }
 
-        final List<MethodNode> methods = classNode.methods;
+    private TypeInfo typeInfo(Type type) {
+        return typeInfoCache.computeIfAbsent(type, k -> {
+            final ClassNode cn = read(k.getClassName());
 
-        for (final MethodNode methodNode : methods) {
-            if (Modifier.isStatic(methodNode.access) && !"<clinit>".equals(methodNode.name)) {
-                result.put(new Method(methodNode.name, methodNode.desc), methodNode);
-            }
-        }
-        methodCache.put(type, result);
-        return result;
+            return new TypeInfo(cn.access, cn.superName,
+                cn.fields.stream().collect(Collectors.toMap(f -> f.name, Function.identity())),
+                cn.methods.stream().collect(Collectors.toMap(m -> new Method(m.name, m.desc), Function.identity())));
+        });
     }
 
     private ClassNode read(final String className) {
         final ClassNode result = new ClassNode(Privilizer.ASM_VERSION);
-        try (InputStream bytecode = privilizer().env.getClassfile(className).getInputStream();) {
+        try (InputStream bytecode = privilizer().env.getClassfile(className).getInputStream()) {
             new ClassReader(bytecode).accept(result, ClassReader.SKIP_DEBUG | ClassReader.EXPAND_FRAMES);
         } catch (final Exception e) {
             throw new RuntimeException(e);
@@ -159,7 +166,7 @@ class BlueprintingVisitor extends Privilizer.PrivilizerClassVisitor {
         privilizer().env.debug("importing %s#%s as %s", key.getLeft().getClassName(), key.getRight(), result);
         final int access = Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC + Opcodes.ACC_SYNTHETIC;
 
-        final MethodNode source = getMethods(key.getLeft()).get(key.getRight());
+        final MethodNode source = typeInfo(key.getLeft()).methods.get(key.getRight());
 
         final String[] exceptions = source.exceptions.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
 
@@ -182,7 +189,7 @@ class BlueprintingVisitor extends Privilizer.PrivilizerClassVisitor {
             new MethodNode(access, result, source.desc, source.signature, exceptions);
 
         // spider own methods:
-        MethodVisitor mv = new NestedMethodInvocationHandler(withAccessibleAdvice, key.getLeft()); //NOPMD
+        MethodVisitor mv = new NestedMethodInvocationHandler(withAccessibleAdvice, key); //NOPMD
 
         if (!fieldAccesses.isEmpty()) {
             mv = new AccessibleAdvisor(mv, access, result, source.desc, new ArrayList<>(fieldAccesses));
@@ -199,49 +206,11 @@ class BlueprintingVisitor extends Privilizer.PrivilizerClassVisitor {
     }
 
     private FieldAccess fieldAccess(final Type owner, final String name) {
-        final Pair<Type, String> key = Pair.of(owner, name);
-        if (!fieldAccessMap.containsKey(key)) {
-            try {
-                final MutableObject<Type> next = new MutableObject<>(owner);
-                final Deque<Type> stk = new ArrayDeque<>();
-                while (next.getValue() != null) {
-                    stk.push(next.getValue());
-                    try (InputStream bytecode =
-                        privilizer().env.getClassfile(next.getValue().getInternalName()).getInputStream()) {
-                        new ClassReader(bytecode).accept(privilizer().new PrivilizerClassVisitor() {
-                            @Override
-                            @SuppressWarnings("PMD.UseVarargs") // overridden method
-                            public void visit(final int version, final int access, final String name,
-                                final String signature, final String superName, final String[] interfaces) {
-                                super.visit(version, access, name, signature, superName, interfaces);
-                                next.setValue(Type.getObjectType(superName));
-                            }
-
-                            @Override
-                            public FieldVisitor visitField(final int access, final String name, final String desc,
-                                final String signature, final Object value) {
-                                for (final Type type : stk) {
-                                    final Pair<Type, String> key = Pair.of(type, name);
-                                    // skip shadowed fields:
-                                    if (!fieldAccessMap.containsKey(key)) {
-                                        fieldAccessMap.put(key,
-                                            new FieldAccess(access, target, name, Type.getType(desc)));
-                                    }
-                                }
-                                return null;
-                            }
-                        }, ClassReader.SKIP_CODE);
-                    }
-                    if (fieldAccessMap.containsKey(key)) {
-                        break;
-                    }
-                }
-            } catch (final Exception e) {
-                throw new RuntimeException(e);
-            }
-            Validate.isTrue(fieldAccessMap.containsKey(key), "Could not locate %s.%s", owner.getClassName(), name);
-        }
-        return fieldAccessMap.get(key);
+        return fieldAccessMap.computeIfAbsent(Pair.of(owner, name), k -> {
+            final FieldNode fieldNode = typeInfo(k.getLeft()).fields.get(k.getRight());
+            Validate.validState(fieldNode != null, "Could not locate %s.%s", k.getLeft().getClassName(), k.getRight());
+            return new FieldAccess(fieldNode.access, k.getLeft(), fieldNode.name, Type.getType(fieldNode.desc));
+        });
     }
 
     @Override
@@ -259,26 +228,109 @@ class BlueprintingVisitor extends Privilizer.PrivilizerClassVisitor {
         public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc,
             final boolean itf) {
             if (opcode == Opcodes.INVOKESTATIC) {
-                final Method methd = new Method(name, desc);
-                final Pair<Type, Method> methodKey = Pair.of(Type.getObjectType(owner), methd);
+                final Pair<Type, Method> methodKey = methodKey(owner, name, desc);
                 if (shouldImport(methodKey)) {
                     final String importedName = importMethod(methodKey);
                     super.visitMethodInsn(opcode, className, importedName, desc, itf);
                     return;
                 }
             }
+            visitNonImportedMethodInsn(opcode, owner, name, desc, itf);
+        }
+
+        protected void visitNonImportedMethodInsn(final int opcode, final String owner, final String name,
+            final String desc, final boolean itf) {
             super.visitMethodInsn(opcode, owner, name, desc, itf);
         }
 
+        @Override
+        public void visitInvokeDynamicInsn(String name, String descriptor, Handle bootstrapMethodHandle,
+            Object... bootstrapMethodArguments) {
+
+            if (isLambda(bootstrapMethodHandle)) {
+                Object[] args = bootstrapMethodArguments;
+
+                Handle handle = null;
+
+                for (int i = 0; i < args.length; i++) {
+                    if (bootstrapMethodArguments[i] instanceof Handle) {
+                        if (handle != null) {
+                            // we don't know what to do with multiple handles; skip the whole thing:
+                            args = bootstrapMethodArguments;
+                            break;
+                        }
+                        handle = (Handle) args[i];
+
+                        if (handle.getTag() == Opcodes.H_INVOKESTATIC) {
+                            final Pair<Type, Method> methodKey =
+                                methodKey(handle.getOwner(), handle.getName(), handle.getDesc());
+
+                            if (shouldImport(methodKey)) {
+                                final String importedName = importMethod(methodKey);
+                                args = bootstrapMethodArguments.clone();
+                                args[i] = new Handle(handle.getTag(), className, importedName, handle.getDesc(), false);
+                            }
+                        }
+                    }
+                }
+                if (handle != null) {
+                    if (args == bootstrapMethodArguments) {
+                        validateLambda(handle);
+                    } else {
+                        super.visitInvokeDynamicInsn(name, descriptor, bootstrapMethodHandle, args);
+                        return;
+                    }
+                }
+            }
+            super.visitInvokeDynamicInsn(name, descriptor, bootstrapMethodHandle, bootstrapMethodArguments);
+        }
+
+        protected void validateLambda(Handle handle) {
+        }
+
         abstract boolean shouldImport(Pair<Type, Method> methodKey);
+
+        private boolean isLambda(Handle handle) {
+            return handle.getTag() == Opcodes.H_INVOKESTATIC
+                && LAMBDA_METAFACTORY.getInternalName().equals(handle.getOwner())
+                && "metafactory".equals(handle.getName());
+        }
     }
 
     class NestedMethodInvocationHandler extends MethodInvocationHandler {
+        final Pair<Type, Method> methodKey;
         final Type owner;
 
-        NestedMethodInvocationHandler(final MethodVisitor mvr, final Type owner) {
+        NestedMethodInvocationHandler(final MethodVisitor mvr, final Pair<Type,Method> methodKey) {
             super(mvr);
-            this.owner = owner;
+            this.methodKey = methodKey;
+            this.owner = methodKey.getLeft();
+        }
+
+        @Override
+        protected void visitNonImportedMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
+            final Type ownerType = Type.getObjectType(owner);
+            final Method m = new Method(name, desc);
+
+            if (isAccessible(ownerType) && isAccessible(ownerType, m)) {
+                super.visitNonImportedMethodInsn(opcode, owner, name, desc, itf);
+            } else {
+                throw new IllegalStateException(String.format("Blueprint method %s.%s calls inaccessible method %s.%s",
+                    this.owner, methodKey.getRight(), owner, m));
+            }
+        }
+
+        @Override
+        protected void validateLambda(Handle handle) {
+            super.validateLambda(handle);
+            final Type ownerType = Type.getObjectType(handle.getOwner());
+            final Method m = new Method(handle.getName(), handle.getDesc());
+
+            if (!(isAccessible(ownerType) && isAccessible(ownerType, m))) {
+                throw new IllegalStateException(
+                    String.format("Blueprint method %s.%s utilizes inaccessible method reference %s::%s", owner,
+                        methodKey.getRight(), handle.getOwner(), m));
+            }
         }
 
         @Override
@@ -301,6 +353,36 @@ class BlueprintingVisitor extends Privilizer.PrivilizerClassVisitor {
         private Class<?> load(final Type type) throws ClassNotFoundException {
             return privilizer().env.classLoader.loadClass(type.getClassName());
         }
+
+        private boolean isAccessible(Type type) {
+            final TypeInfo typeInfo = typeInfo(type);
+            return isAccessible(type, typeInfo.access);
+        }
+
+        private boolean isAccessible(Type type, Method m) {
+            Type t = type;
+            while (t != null) {
+                final TypeInfo typeInfo = typeInfo(t);
+                final MethodNode methodNode = typeInfo.methods.get(m);
+                if (methodNode == null) {
+                    t = Optional.ofNullable(typeInfo.superName).map(Type::getObjectType).orElse(null);
+                    continue;
+                }
+                return isAccessible(type, methodNode.access);
+            }
+            throw new IllegalStateException(String.format("Cannot find method %s.%s", type, m));
+        }
+
+        private boolean isAccessible(Type type, int access) {
+            if (Modifier.isPublic(access)) {
+                return true;
+            }
+            if (Modifier.isProtected(access) || Modifier.isPrivate(access)) {
+                return false;
+            }
+            return Stream.of(target, type).map(Type::getInternalName).map(n -> StringUtils.substringBeforeLast(n, "/"))
+                    .distinct().count() == 1;
+        }
     }
 
     /**
@@ -424,7 +506,7 @@ class BlueprintingVisitor extends Privilizer.PrivilizerClassVisitor {
             invokeVirtual(fieldType, access);
 
             if (opcode == GETSTATIC) {
-                checkCast(privilizer().wrap(fieldAccess.type));
+                checkCast(Privilizer.wrap(fieldAccess.type));
                 if (fieldAccess.type.getSort() < Type.ARRAY) {
                     unbox(fieldAccess.type);
                 }
diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
index 5da66bd..50f84f4 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
@@ -174,28 +174,7 @@ public class Privilizer {
     static final int ASM_VERSION = Opcodes.ASM5;
     static final Type[] EMPTY_TYPE_ARRAY = new Type[0];
 
-    final WeaveEnvironment env;
-    final AccessLevel accessLevel;
-    final Policy policy;
-    final boolean verify;
-
-    /**
-     * Create a new {@link Privilizer}.
-     * @param env to use
-     */
-    public Privilizer(final 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));
-        verify = BooleanUtils.toBoolean(env.config.getProperty(CONFIG_VERIFY));
-    }
-
-    String generateName(final String simple) {
-        return String.format(GENERATE_NAME, simple);
-    }
-
-    Type wrap(final Type type) {
+    static Type wrap(final Type type) {
         switch (type.getSort()) {
         case Type.BOOLEAN:
             return Type.getType(Boolean.class);
@@ -220,6 +199,27 @@ public class Privilizer {
         }
     }
 
+    final WeaveEnvironment env;
+    final AccessLevel accessLevel;
+    final Policy policy;
+    final boolean verify;
+
+    /**
+     * Create a new {@link Privilizer}.
+     * @param env to use
+     */
+    public Privilizer(final 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));
+        verify = BooleanUtils.toBoolean(env.config.getProperty(CONFIG_VERIFY));
+    }
+
+    String generateName(final String simple) {
+        return String.format(GENERATE_NAME, simple);
+    }
+
     void blueprint(final Class<?> type, final Privilizing privilizing) {
         final Object[] args = { type.getName(), privilizing };
         env.debug("blueprinting class %s %s", args);

-- 
To stop receiving notification emails like this one, please contact
mbenson@apache.org.

[commons-weaver] 06/13: upgrade japicmp

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mbenson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-weaver.git

commit 08ac94ddeecac78a9bfeffdb7cfc77934e7662d1
Author: Matt Benson <mb...@apache.org>
AuthorDate: Fri Apr 20 11:19:35 2018 -0500

    upgrade japicmp
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index c3bf4cc..73330bd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -57,7 +57,7 @@ under the License.
     <commons.site.path>commons-weaver</commons.site.path>
     <commons.scmPubUrl>https://svn.apache.org/repos/infra/websites/production/commons/content/proper/${commons.site.path}</commons.scmPubUrl>
 
-    <commons.japicmp.version>0.9.1</commons.japicmp.version>
+    <commons.japicmp.version>0.11.1</commons.japicmp.version>
 
     <!-- most Java-related items are defined in parent/pom.xml;
          define these here for the animal-sniffer config of commons-parent: -->

-- 
To stop receiving notification emails like this one, please contact
mbenson@apache.org.

[commons-weaver] 09/13: small cleanups

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mbenson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-weaver.git

commit 1c6c4e3dc4666dfa3ad86feefb197f8df34c7ade
Author: Matt Benson <mb...@apache.org>
AuthorDate: Fri Apr 20 11:32:34 2018 -0500

    small cleanups
---
 .../java/org/apache/commons/weaver/normalizer/Normalizer.java | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Normalizer.java b/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Normalizer.java
index d0be3dd..67b1c40 100644
--- a/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Normalizer.java
+++ b/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Normalizer.java
@@ -21,7 +21,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Target;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.text.MessageFormat;
@@ -35,7 +35,6 @@ import java.util.stream.Stream;
 import javax.activation.DataSource;
 
 import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.CharEncoding;
 import org.apache.commons.lang3.Conversion;
 import org.apache.commons.lang3.Validate;
 import org.apache.commons.lang3.mutable.MutableBoolean;
@@ -291,7 +290,6 @@ public class Normalizer {
     public static final String CONFIG_TARGET_PACKAGE = CONFIG_WEAVER + "targetPackage";
 
     private static final int ASM_VERSION = Opcodes.ASM5;
-    private static final Charset UTF8 = Charset.forName(CharEncoding.UTF_8);
 
     private final WeaveEnvironment env;
 
@@ -491,8 +489,8 @@ public class Normalizer {
         } catch (final NoSuchAlgorithmException e) {
             throw new RuntimeException(e);
         }
-        md5.update(key.getLeft().getBytes(UTF8));
-        md5.update(key.getRight().getBytes(UTF8));
+        md5.update(key.getLeft().getBytes(StandardCharsets.UTF_8));
+        md5.update(key.getRight().getBytes(StandardCharsets.UTF_8));
 
         final long digest = Conversion.byteArrayToLong(md5.digest(), 0, 0L, 0, Long.SIZE / Byte.SIZE);
 
@@ -525,7 +523,6 @@ public class Normalizer {
                 public MethodVisitor visitMethod(final int access, final String name, final String desc,
                     final String signature, final String[] exceptions) {
                     if (INIT.equals(name)) {
-
                         final Method staticCtor = new Method(INIT, key.getRight());
                         final Type[] argumentTypes = staticCtor.getArgumentTypes();
                         final Type[] exceptionTypes = toObjectTypes(exceptions);
@@ -551,7 +548,7 @@ public class Normalizer {
                          */
                         {
                             final Method instanceCtor =
-                                new Method(INIT, Type.VOID_TYPE, ArrayUtils.add(argumentTypes, 0, OBJECT_TYPE));
+                                new Method(INIT, Type.VOID_TYPE, ArrayUtils.insert(0, argumentTypes, OBJECT_TYPE));
                             final GeneratorAdapter mgen =
                                 new GeneratorAdapter(Opcodes.ACC_PUBLIC, instanceCtor, signature, exceptionTypes,
                                     writeClass);

-- 
To stop receiving notification emails like this one, please contact
mbenson@apache.org.

[commons-weaver] 01/13: Java 8; assorted minor refactorings

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mbenson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-weaver.git

commit 901ba1ae923352168dc5857c3b3d462a915f7e0f
Author: Gary D. Gregory <gg...@apache.org>
AuthorDate: Sun Jan 7 20:53:24 2018 +0000

    Java 8; assorted minor refactorings
---
 BUILDING.txt                                       |   2 +-
 ant/pom.xml                                        |   1 -
 .../commons/weaver/ant/AbstractWeaverTask.java     |   1 -
 .../org/apache/commons/weaver/ant/CleanTask.java   |   4 +-
 .../org/apache/commons/weaver/ant/WeaveTask.java   |   4 +-
 .../apache/commons/weaver/ant/WeaverSettings.java  |   2 -
 maven-plugin/pom.xml                               |   2 +-
 .../commons/weaver/maven/AbstractCWMojo.java       |  12 +-
 .../commons/weaver/maven/AbstractPrepareMojo.java  |   4 +-
 .../commons/weaver/maven/AbstractWeaveMojo.java    |   4 +-
 .../maven/JavaLoggingToMojoLoggingRedirector.java  |  21 +-
 .../apache/commons/weaver/maven/PrepareMojo.java   |   1 -
 .../commons/weaver/maven/TestPrepareMojo.java      |   1 -
 .../apache/commons/weaver/maven/TestWeaveMojo.java |   1 -
 .../org/apache/commons/weaver/maven/WeaveMojo.java |   1 -
 modules/normalizer/pom.xml                         |   2 -
 .../commons/weaver/normalizer/Normalizer.java      |  65 ++---
 .../weaver/normalizer/NormalizerWeaver.java        |   1 -
 .../apache/commons/weaver/normalizer/Utils.java    |   9 +-
 modules/privilizer/weaver/pom.xml                  |   3 -
 .../commons/weaver/privilizer/ActionGenerator.java |   8 +-
 .../weaver/privilizer/BlueprintingVisitor.java     |  52 ++--
 .../apache/commons/weaver/privilizer/Field.java    |  12 +-
 .../commons/weaver/privilizer/FieldAccess.java     |   1 -
 .../apache/commons/weaver/privilizer/Policy.java   |   1 -
 .../commons/weaver/privilizer/Privilizer.java      |  23 +-
 .../weaver/privilizer/PrivilizerCleaner.java       |  11 +-
 .../weaver/privilizer/PrivilizerWeaver.java        |   2 +-
 .../weaver/privilizer/PrivilizingVisitor.java      |   5 +-
 pom.xml                                            |   9 +-
 .../org/apache/commons/weaver/CleanProcessor.java  |   2 +-
 .../java/org/apache/commons/weaver/Finder.java     | 281 +++++++--------------
 .../java/org/apache/commons/weaver/Inflater.java   |  88 +++----
 .../org/apache/commons/weaver/ProcessorBase.java   |   4 +-
 .../org/apache/commons/weaver/WeaveProcessor.java  |   2 +-
 .../apache/commons/weaver/model/ScanRequest.java   |   4 +-
 .../apache/commons/weaver/model/ScanResult.java    |   9 +-
 .../org/apache/commons/weaver/model/Weavable.java  |   2 +-
 .../apache/commons/weaver/model/WeavableClass.java |  39 +--
 .../commons/weaver/model/WeavableConstructor.java  |   1 -
 .../weaver/model/WeavableConstructorParameter.java |   1 -
 .../commons/weaver/model/WeavableExecutable.java   |   3 +-
 .../commons/weaver/model/WeavableMethod.java       |   2 +-
 .../weaver/model/WeavableMethodParameter.java      |   1 -
 .../commons/weaver/model/WeavablePackage.java      |   6 +-
 .../commons/weaver/model/WeavableParameter.java    |   1 -
 .../commons/weaver/model/WeaveEnvironment.java     |  37 +--
 .../apache/commons/weaver/model/WeaveInterest.java |  20 +-
 .../java/org/apache/commons/weaver/utils/Args.java |   1 -
 .../org/apache/commons/weaver/utils/Providers.java |  33 +--
 .../org/apache/commons/weaver/utils/URLArray.java  |  60 ++---
 51 files changed, 300 insertions(+), 562 deletions(-)

diff --git a/BUILDING.txt b/BUILDING.txt
deleted file mode 120000
index 5af3810..0000000
--- a/BUILDING.txt
+++ /dev/null
@@ -1 +0,0 @@
-src/site/markdown/building.md
\ No newline at end of file
diff --git a/BUILDING.txt b/BUILDING.txt
new file mode 100644
index 0000000..0fcdf1e
--- /dev/null
+++ b/BUILDING.txt
@@ -0,0 +1 @@
+link src/site/markdown/building.md
\ No newline at end of file
diff --git a/ant/pom.xml b/ant/pom.xml
index dd472ae..0db620b 100644
--- a/ant/pom.xml
+++ b/ant/pom.xml
@@ -111,7 +111,6 @@ under the License.
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-shade-plugin</artifactId>
-        <version>2.1</version>
         <executions>
           <execution>
             <id>shade</id>
diff --git a/ant/src/main/java/org/apache/commons/weaver/ant/AbstractWeaverTask.java b/ant/src/main/java/org/apache/commons/weaver/ant/AbstractWeaverTask.java
index fde4f9e..50c66c9 100644
--- a/ant/src/main/java/org/apache/commons/weaver/ant/AbstractWeaverTask.java
+++ b/ant/src/main/java/org/apache/commons/weaver/ant/AbstractWeaverTask.java
@@ -66,5 +66,4 @@ public abstract class AbstractWeaverTask extends Task {
         settings.setRefid(new Reference(getProject(), refid));
         add(settings);
     }
-
 }
\ No newline at end of file
diff --git a/ant/src/main/java/org/apache/commons/weaver/ant/CleanTask.java b/ant/src/main/java/org/apache/commons/weaver/ant/CleanTask.java
index a91f9da..1756958 100644
--- a/ant/src/main/java/org/apache/commons/weaver/ant/CleanTask.java
+++ b/ant/src/main/java/org/apache/commons/weaver/ant/CleanTask.java
@@ -42,9 +42,7 @@ public class CleanTask extends AbstractWeaverTask {
     public void execute() {
         try {
             final WeaverSettings settings = Validate.notNull(getSettings(), "settings");
-            final CleanProcessor cleanProcessor =
-                new CleanProcessor(settings.getClasspathEntries(), settings.getTarget(), settings.getProperties());
-            cleanProcessor.clean();
+            new CleanProcessor(settings.getClasspathEntries(), settings.getTarget(), settings.getProperties()).clean();
         } catch (final Exception e) {
             throw new BuildException(e);
         }
diff --git a/ant/src/main/java/org/apache/commons/weaver/ant/WeaveTask.java b/ant/src/main/java/org/apache/commons/weaver/ant/WeaveTask.java
index 414bfb7..31ab7f4 100644
--- a/ant/src/main/java/org/apache/commons/weaver/ant/WeaveTask.java
+++ b/ant/src/main/java/org/apache/commons/weaver/ant/WeaveTask.java
@@ -42,9 +42,7 @@ public class WeaveTask extends AbstractWeaverTask {
     public void execute() {
         try {
             final WeaverSettings settings = Validate.notNull(getSettings(), "settings");
-            final WeaveProcessor weaveProcessor =
-                new WeaveProcessor(settings.getClasspathEntries(), settings.getTarget(), settings.getProperties());
-            weaveProcessor.weave();
+            new WeaveProcessor(settings.getClasspathEntries(), settings.getTarget(), settings.getProperties()).weave();
         } catch (final Exception e) {
             throw new BuildException(e);
         }
diff --git a/ant/src/main/java/org/apache/commons/weaver/ant/WeaverSettings.java b/ant/src/main/java/org/apache/commons/weaver/ant/WeaverSettings.java
index 5533f5f..0686e2f 100644
--- a/ant/src/main/java/org/apache/commons/weaver/ant/WeaverSettings.java
+++ b/ant/src/main/java/org/apache/commons/weaver/ant/WeaverSettings.java
@@ -121,7 +121,6 @@ public class WeaverSettings extends DataType {
         if (includeSystemClasspath) {
             path.add(Path.systemClasspath);
         }
-
         return Arrays.asList(path.list());
     }
 
@@ -227,5 +226,4 @@ public class WeaverSettings extends DataType {
     private WeaverSettings getRef() {
         return getCheckedRef(WeaverSettings.class, "settings");
     }
-
 }
\ No newline at end of file
diff --git a/maven-plugin/pom.xml b/maven-plugin/pom.xml
index 465bc0c..d7ebb30 100644
--- a/maven-plugin/pom.xml
+++ b/maven-plugin/pom.xml
@@ -35,7 +35,7 @@ under the License.
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <maven.version>3.1.0</maven.version>
-    <maven.plugin.version>3.1</maven.plugin.version>
+    <maven.plugin.version>3.5.1</maven.plugin.version>
     <aether.version>1.1.0</aether.version>
   </properties>
 
diff --git a/maven-plugin/src/main/java/org/apache/commons/weaver/maven/AbstractCWMojo.java b/maven-plugin/src/main/java/org/apache/commons/weaver/maven/AbstractCWMojo.java
index 46f6500..0387719 100755
--- a/maven-plugin/src/main/java/org/apache/commons/weaver/maven/AbstractCWMojo.java
+++ b/maven-plugin/src/main/java/org/apache/commons/weaver/maven/AbstractCWMojo.java
@@ -23,11 +23,9 @@ import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
-import java.util.ArrayList;
-import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Properties;
-import java.util.Set;
+import java.util.stream.Collectors;
 
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -42,7 +40,6 @@ import org.apache.maven.project.MavenProject;
 import org.eclipse.aether.RepositorySystem;
 import org.eclipse.aether.RepositorySystemSession;
 import org.eclipse.aether.collection.CollectRequest;
-import org.eclipse.aether.resolution.ArtifactResult;
 import org.eclipse.aether.resolution.DependencyRequest;
 import org.eclipse.aether.resolution.DependencyResolutionException;
 import org.eclipse.aether.resolution.DependencyResult;
@@ -139,11 +136,8 @@ abstract class AbstractCWMojo extends AbstractMojo {
             repositorySystem.resolveDependencies(repositorySystemSession, new DependencyRequest()
                 .setFilter(new ScopeDependencyFilter(getExcludeScopes())).setCollectRequest(collect));
 
-        final Set<String> result = new LinkedHashSet<String>();
-        for (final ArtifactResult artifactResult : dependencyResult.getArtifactResults()) {
-            result.add(artifactResult.getArtifact().getFile().getAbsolutePath());
-        }
-        return new ArrayList<String>(result);
+        return dependencyResult.getArtifactResults().stream().map(ar -> ar.getArtifact().getFile().getAbsolutePath())
+            .distinct().collect(Collectors.toList());
     }
 
     private String[] getExcludeScopes() {
diff --git a/maven-plugin/src/main/java/org/apache/commons/weaver/maven/AbstractPrepareMojo.java b/maven-plugin/src/main/java/org/apache/commons/weaver/maven/AbstractPrepareMojo.java
index 4160648..8555626 100644
--- a/maven-plugin/src/main/java/org/apache/commons/weaver/maven/AbstractPrepareMojo.java
+++ b/maven-plugin/src/main/java/org/apache/commons/weaver/maven/AbstractPrepareMojo.java
@@ -37,11 +37,9 @@ public abstract class AbstractPrepareMojo extends AbstractCWMojo {
             return;
         }
         try {
-            final CleanProcessor cleanProcessor = new CleanProcessor(classpath, target, config);
-            cleanProcessor.clean();
+            new CleanProcessor(classpath, target, config).clean();
         } catch (Exception e) {
             throw new MojoExecutionException("cleaning failed due to " + e.getMessage(), e);
         }
     }
-
 }
diff --git a/maven-plugin/src/main/java/org/apache/commons/weaver/maven/AbstractWeaveMojo.java b/maven-plugin/src/main/java/org/apache/commons/weaver/maven/AbstractWeaveMojo.java
index 8af0ab1..6638a2e 100644
--- a/maven-plugin/src/main/java/org/apache/commons/weaver/maven/AbstractWeaveMojo.java
+++ b/maven-plugin/src/main/java/org/apache/commons/weaver/maven/AbstractWeaveMojo.java
@@ -34,11 +34,9 @@ public abstract class AbstractWeaveMojo extends AbstractCWMojo {
     protected void doExecute(final File target, final List<String> classpath, final Properties config)
         throws MojoExecutionException {
         try {
-            final WeaveProcessor weaveProcessor = new WeaveProcessor(classpath, target, config);
-            weaveProcessor.weave();
+            new WeaveProcessor(classpath, target, config).weave();
         } catch (Exception e) {
             throw new MojoExecutionException("weaving failed due to " + e.getMessage(), e);
         }
     }
-
 }
diff --git a/maven-plugin/src/main/java/org/apache/commons/weaver/maven/JavaLoggingToMojoLoggingRedirector.java b/maven-plugin/src/main/java/org/apache/commons/weaver/maven/JavaLoggingToMojoLoggingRedirector.java
index 69f5313..4534cec 100644
--- a/maven-plugin/src/main/java/org/apache/commons/weaver/maven/JavaLoggingToMojoLoggingRedirector.java
+++ b/maven-plugin/src/main/java/org/apache/commons/weaver/maven/JavaLoggingToMojoLoggingRedirector.java
@@ -27,6 +27,7 @@ import java.util.logging.Level;
 import java.util.logging.LogManager;
 import java.util.logging.LogRecord;
 import java.util.logging.Logger;
+import java.util.stream.Stream;
 
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -36,7 +37,7 @@ import org.apache.maven.plugin.logging.Log;
  * This class redirects calls to java.util Logging to Mojo logging.
  */
 public class JavaLoggingToMojoLoggingRedirector {
-    private final List<Handler> removedHandlers = new ArrayList<Handler>();
+    private final List<Handler> removedHandlers = new ArrayList<>();
 
     /**
      * The Maven mojo logger to delegate messages to.
@@ -68,12 +69,10 @@ public class JavaLoggingToMojoLoggingRedirector {
             if (removedHandlers.isEmpty()) {
                 throw new MojoExecutionException("could not remove any handler. aborting.");
             }
-
             // add our own
             activeHandler = new JDKLogHandler();
             activeHandler.setLevel(Level.ALL);
             rootLogger.setLevel(Level.ALL);
-
             rootLogger.addHandler(activeHandler);
         } catch (Exception exc) {
             throw new MojoExecutionException("failed to activate the jul logging redirector", exc);
@@ -87,15 +86,11 @@ public class JavaLoggingToMojoLoggingRedirector {
     public void deactivate() {
         final Logger rootLogger = LogManager.getLogManager().getLogger("");
         // remove old handlers
-        for (final Handler handler : rootLogger.getHandlers()) {
-            if (handler == activeHandler) {
-                rootLogger.removeHandler(handler);
-            }
-        }
-
-        for (final Handler oldHandler : removedHandlers) {
-            rootLogger.addHandler(oldHandler);
+        
+        if (Stream.of(rootLogger.getHandlers()).anyMatch(h -> h == activeHandler)) {
+            rootLogger.removeHandler(activeHandler);
         }
+        removedHandlers.forEach(rootLogger::addHandler);
     }
 
     private class JDKLogHandler extends Handler {
@@ -133,7 +128,6 @@ public class JavaLoggingToMojoLoggingRedirector {
 
         private String getMessage(final LogRecord record) {
             final ResourceBundle bundle = record.getResourceBundle();
-            final Object[] params = record.getParameters();
             final String message;
             if (bundle != null && bundle.containsKey(record.getMessage())) {
                 // todo: cannot enforce Locale.ENGLISH here
@@ -141,6 +135,7 @@ public class JavaLoggingToMojoLoggingRedirector {
             } else {
                 message = record.getMessage();
             }
+            final Object[] params = record.getParameters();
             if (ArrayUtils.isNotEmpty(params)) {
                 return new MessageFormat(message).format(params);
             }
@@ -156,7 +151,5 @@ public class JavaLoggingToMojoLoggingRedirector {
         public void close() {
             // nothing to do
         }
-
     }
-
 }
diff --git a/maven-plugin/src/main/java/org/apache/commons/weaver/maven/PrepareMojo.java b/maven-plugin/src/main/java/org/apache/commons/weaver/maven/PrepareMojo.java
index eda7622..810c9f8 100644
--- a/maven-plugin/src/main/java/org/apache/commons/weaver/maven/PrepareMojo.java
+++ b/maven-plugin/src/main/java/org/apache/commons/weaver/maven/PrepareMojo.java
@@ -49,5 +49,4 @@ public class PrepareMojo extends AbstractPrepareMojo {
     protected File getTarget() {
         return target;
     }
-
 }
diff --git a/maven-plugin/src/main/java/org/apache/commons/weaver/maven/TestPrepareMojo.java b/maven-plugin/src/main/java/org/apache/commons/weaver/maven/TestPrepareMojo.java
index 849d5e9..79ce5eb 100644
--- a/maven-plugin/src/main/java/org/apache/commons/weaver/maven/TestPrepareMojo.java
+++ b/maven-plugin/src/main/java/org/apache/commons/weaver/maven/TestPrepareMojo.java
@@ -51,5 +51,4 @@ public class TestPrepareMojo extends AbstractPrepareMojo {
     protected File getTarget() {
         return target;
     }
-
 }
diff --git a/maven-plugin/src/main/java/org/apache/commons/weaver/maven/TestWeaveMojo.java b/maven-plugin/src/main/java/org/apache/commons/weaver/maven/TestWeaveMojo.java
index db714f6..af5c77d 100644
--- a/maven-plugin/src/main/java/org/apache/commons/weaver/maven/TestWeaveMojo.java
+++ b/maven-plugin/src/main/java/org/apache/commons/weaver/maven/TestWeaveMojo.java
@@ -60,5 +60,4 @@ public class TestWeaveMojo extends AbstractWeaveMojo {
     protected File getTarget() {
         return target;
     }
-
 }
diff --git a/maven-plugin/src/main/java/org/apache/commons/weaver/maven/WeaveMojo.java b/maven-plugin/src/main/java/org/apache/commons/weaver/maven/WeaveMojo.java
index a5d37af..ecdc025 100644
--- a/maven-plugin/src/main/java/org/apache/commons/weaver/maven/WeaveMojo.java
+++ b/maven-plugin/src/main/java/org/apache/commons/weaver/maven/WeaveMojo.java
@@ -50,5 +50,4 @@ public class WeaveMojo extends AbstractWeaveMojo {
     protected File getTarget() {
         return target;
     }
-
 }
diff --git a/modules/normalizer/pom.xml b/modules/normalizer/pom.xml
index 53a9e77..d27fcd8 100644
--- a/modules/normalizer/pom.xml
+++ b/modules/normalizer/pom.xml
@@ -120,7 +120,6 @@ under the License.
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-shade-plugin</artifactId>
-        <version>2.1</version>
         <executions>
           <execution>
             <id>shade</id>
@@ -233,7 +232,6 @@ under the License.
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-dependency-plugin</artifactId>
-        <version>2.10</version>
         <executions>
           <execution>
             <id>it-compile-deps</id>
diff --git a/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Normalizer.java b/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Normalizer.java
index 0ead390..b469c88 100644
--- a/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Normalizer.java
+++ b/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Normalizer.java
@@ -30,6 +30,7 @@ import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Set;
+import java.util.stream.Stream;
 
 import javax.activation.DataSource;
 
@@ -96,7 +97,7 @@ public class Normalizer {
             }
         }
 
-        private final MutablePair<String, String> key = new MutablePair<String, String>();
+        private final MutablePair<String, String> key = new MutablePair<>();
         private final MutableBoolean ignore = new MutableBoolean(false);
         private final MutableBoolean valid = new MutableBoolean(true);
         private final MutableBoolean mustRewriteConstructor = new MutableBoolean(false);
@@ -262,14 +263,10 @@ public class Normalizer {
 
             final DataSource classfile = env.getClassfile(className);
             env.debug("Writing class %s to %s", className, classfile.getName());
-            OutputStream outputStream = null;
-            try {
-                outputStream = classfile.getOutputStream();
+            try (OutputStream outputStream = classfile.getOutputStream()) {
                 IOUtils.write(bytecode, outputStream);
             } catch (final IOException e) {
                 throw new RuntimeException(e);
-            } finally {
-                IOUtils.closeQuietly(outputStream);
             }
         }
     }
@@ -350,15 +347,10 @@ public class Normalizer {
      * @return {@link Map} of enclosing classname to {@link Map} of internal name to {@link ClassWrapper}
      */
     private Map<String, Map<String, ClassWrapper>> byEnclosingClass(final Set<ClassWrapper> sort) {
-        final Map<String, Map<String, ClassWrapper>> result = new HashMap<String, Map<String, ClassWrapper>>();
+        final Map<String, Map<String, ClassWrapper>> result = new HashMap<>();
         for (final ClassWrapper wrapper : sort) {
-            final String outer = wrapper.wrapped.getEnclosingClass().getName();
-            Map<String, ClassWrapper> map = result.get(outer);
-            if (map == null) {
-                map = new LinkedHashMap<String, Normalizer.ClassWrapper>();
-                result.put(outer, map);
-            }
-            map.put(wrapper.wrapped.getName().replace('.', '/'), wrapper);
+            result.computeIfAbsent(wrapper.wrapped.getEnclosingClass().getName(), k -> new LinkedHashMap<>())
+                .put(wrapper.wrapped.getName().replace('.', '/'), wrapper);
         }
         return result;
     }
@@ -380,19 +372,15 @@ public class Normalizer {
         for (final Map.Entry<String, Map<String, ClassWrapper>> entry : byEnclosingClass.entrySet()) {
             final String outer = entry.getKey();
             env.debug("Normalizing %s inner classes of %s", entry.getValue().size(), outer);
-            final Map<String, String> classMap = new HashMap<String, String>();
+            final Map<String, String> classMap = new HashMap<>();
             for (final String merged : entry.getValue().keySet()) {
                 classMap.put(merged, target);
             }
             final Remapper remapper = new SimpleRemapper(classMap);
 
-            InputStream enclosingBytecode = null;
-            try {
-                enclosingBytecode = env.getClassfile(outer).getInputStream();
+            try (InputStream enclosingBytecode = env.getClassfile(outer).getInputStream()) {
                 final ClassReader reader = new ClassReader(enclosingBytecode);
                 reader.accept(new Remap(new WriteClass(reader), remapper, classMap, entry.getValue()), 0);
-            } finally {
-                IOUtils.closeQuietly(enclosingBytecode);
             }
             for (final String merged : entry.getValue().keySet()) {
                 if (env.deleteClassfile(merged)) {
@@ -422,7 +410,7 @@ public class Normalizer {
      */
     private Set<Class<?>> getBroadlyEligibleSubclasses(final Class<?> supertype, final Scanner scanner) {
         final ScanResult scanResult = scanner.scan(new ScanRequest().addSupertypes(supertype));
-        final Set<Class<?>> result = new LinkedHashSet<Class<?>>();
+        final Set<Class<?>> result = new LinkedHashSet<>();
         for (final WeavableClass<?> cls : scanResult.getClasses()) {
             final Class<?> subtype = cls.getTarget();
             final IneligibilityReason reason;
@@ -464,28 +452,18 @@ public class Normalizer {
      */
     private Map<Pair<String, String>, Set<ClassWrapper>> segregate(final Iterable<Class<?>> subtypes)
         throws IOException {
-        final Map<Pair<String, String>, Set<ClassWrapper>> classMap =
-            new LinkedHashMap<Pair<String, String>, Set<ClassWrapper>>();
+        final Map<Pair<String, String>, Set<ClassWrapper>> classMap = new LinkedHashMap<>();
         for (final Class<?> subtype : subtypes) {
             final Inspector inspector = new Inspector();
-            InputStream bytecode = null;
-            try {
-                bytecode = env.getClassfile(subtype).getInputStream();
+            try (InputStream bytecode = env.getClassfile(subtype).getInputStream()) {
                 new ClassReader(bytecode).accept(inspector, 0);
-            } finally {
-                IOUtils.closeQuietly(bytecode);
             }
             if (inspector.ignore()) {
                 continue;
             }
             if (inspector.valid()) {
-                final Pair<String, String> key = inspector.key();
-                Set<ClassWrapper> set = classMap.get(key);
-                if (set == null) {
-                    set = new LinkedHashSet<ClassWrapper>();
-                    classMap.put(key, set);
-                }
-                set.add(new ClassWrapper(subtype, inspector.mustRewriteConstructor()));
+                classMap.computeIfAbsent(inspector.key(), k -> new LinkedHashSet<>())
+                    .add(new ClassWrapper(subtype, inspector.mustRewriteConstructor()));
             } else {
                 env.debug("%s is ineligible for normalization due to %s", subtype,
                     IneligibilityReason.TOO_BUSY_CONSTRUCTOR);
@@ -522,10 +500,7 @@ public class Normalizer {
 
         env.debug("Copying class %s to %s", classWrapper.wrapped.getName(), result);
 
-        InputStream bytecode = null;
-
-        try {
-            bytecode = env.getClassfile(classWrapper.wrapped).getInputStream();
+        try (InputStream bytecode = env.getClassfile(classWrapper.wrapped).getInputStream()) {
             final ClassReader reader = new ClassReader(bytecode);
 
             final ClassVisitor writeClass = new WriteClass();
@@ -542,7 +517,6 @@ public class Normalizer {
                     final String superName, final String[] interfaces) {
                     supertype = Type.getObjectType(superName);
                     writeClass.visit(version, Opcodes.ACC_PUBLIC, result, signature, superName, interfaces);
-
                     visitAnnotation(Type.getType(Marker.class).getDescriptor(), false);
                 }
 
@@ -600,8 +574,6 @@ public class Normalizer {
                     writeClass.visitEnd();
                 }
             }, 0);
-        } finally {
-            IOUtils.closeQuietly(bytecode);
         }
         return result;
     }
@@ -614,13 +586,6 @@ public class Normalizer {
      */
     @SuppressWarnings("PMD.UseVarargs") //varargs not needed here
     private static Type[] toObjectTypes(final String[] types) {
-        if (types == null) {
-            return null;
-        }
-        final Type[] result = new Type[types.length];
-        for (int i = 0; i < types.length; i++) {
-            result[i] = Type.getObjectType(types[i]);
-        }
-        return result;
+        return types == null ? null : Stream.of(types).map(Type::getObjectType).toArray(Type[]::new);
     }
 }
diff --git a/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/NormalizerWeaver.java b/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/NormalizerWeaver.java
index 0b8693a..aa769ac 100644
--- a/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/NormalizerWeaver.java
+++ b/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/NormalizerWeaver.java
@@ -35,5 +35,4 @@ public class NormalizerWeaver implements Weaver {
     public boolean process(final WeaveEnvironment environment, final Scanner scanner) {
         return new Normalizer(environment).normalize(scanner);
     }
-
 }
diff --git a/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Utils.java b/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Utils.java
index 93d1bea..1192694 100644
--- a/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Utils.java
+++ b/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Utils.java
@@ -27,9 +27,6 @@ import org.apache.commons.lang3.Validate;
  * Normalization utilities.
  */
 final class Utils {
-    private Utils() {
-    }
-
     /**
      * Validate a package name.
      * @param pkg to validate
@@ -59,7 +56,6 @@ final class Utils {
             }
             Validate.isTrue(Character.isJavaIdentifierPart(chr), unexpected, chr, pos, result);
         }
-
         result = result.replace('.', '/');
         final int last = result.length() - 1;
         if (result.charAt(last) == '/') {
@@ -77,7 +73,7 @@ final class Utils {
      * @return {@link Set} of {@link Class}
      */
     static Set<Class<?>> parseTypes(final String types, final ClassLoader classLoader) {
-        final Set<Class<?>> result = new LinkedHashSet<Class<?>>();
+        final Set<Class<?>> result = new LinkedHashSet<>();
         for (final String token : StringUtils.splitByWholeSeparatorPreserveAllTokens(types, ",")) {
             try {
                 result.add(ClassUtils.getClass(classLoader, token.trim().replace('/', '.')));
@@ -87,4 +83,7 @@ final class Utils {
         }
         return result;
     }
+
+    private Utils() {
+    }
 }
diff --git a/modules/privilizer/weaver/pom.xml b/modules/privilizer/weaver/pom.xml
index 09eeb42..bef4e15 100644
--- a/modules/privilizer/weaver/pom.xml
+++ b/modules/privilizer/weaver/pom.xml
@@ -41,7 +41,6 @@ under the License.
     <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-weaver-privilizer-api</artifactId>
-      <version>${project.version}</version>
     </dependency>
     <dependency>
       <groupId>org.apache.commons</groupId>
@@ -90,7 +89,6 @@ under the License.
           <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-shade-plugin</artifactId>
-            <version>2.1</version>
             <executions>
               <execution>
                 <id>shade</id>
@@ -163,7 +161,6 @@ under the License.
     <plugins>
       <plugin>
         <artifactId>maven-invoker-plugin</artifactId>
-        <version>2.0.0</version>
         <configuration>
           <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
           <settingsFile>src/it/settings.xml</settingsFile>
diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/ActionGenerator.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/ActionGenerator.java
index a30fae8..20f2121 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/ActionGenerator.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/ActionGenerator.java
@@ -157,8 +157,7 @@ class ActionGenerator extends Privilizer.WriteClass implements Builder<Type> {
         final SignatureVisitor actionImplemented = type.visitInterface();
         actionImplemented.visitClassType(actionInterface.getInternalName());
         final SignatureVisitor visitTypeArgument = actionImplemented.visitTypeArgument('=');
-        final SignatureReader result = new SignatureReader(privilizer().wrap(methd.getReturnType()).getDescriptor());
-        result.accept(visitTypeArgument);
+        new SignatureReader(privilizer().wrap(methd.getReturnType()).getDescriptor()).accept(visitTypeArgument);
         actionImplemented.visitEnd();
 
         final String signature = type.toString();
@@ -194,7 +193,6 @@ class ActionGenerator extends Privilizer.WriteClass implements Builder<Type> {
             mgen.loadArg(arg++);
             mgen.putField(action, field.name, field.type);
         }
-
         mgen.returnValue();
         final Label end = mgen.mark();
 
@@ -219,16 +217,12 @@ class ActionGenerator extends Privilizer.WriteClass implements Builder<Type> {
             mgen.loadThis();
             mgen.getField(action, field.name, field.type);
         }
-
         mgen.invokeStatic(owner.target, helper);
 
         if (methd.getReturnType().getSort() < Type.ARRAY) {
             mgen.valueOf(methd.getReturnType());
         }
-
         mgen.returnValue();
-
         mgen.endMethod();
     }
-
 }
diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/BlueprintingVisitor.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/BlueprintingVisitor.java
index ba2108a..00a7049 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/BlueprintingVisitor.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/BlueprintingVisitor.java
@@ -31,7 +31,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.Validate;
 import org.apache.commons.lang3.mutable.MutableObject;
@@ -54,27 +53,27 @@ import org.objectweb.asm.tree.MethodNode;
  */
 class BlueprintingVisitor extends Privilizer.PrivilizerClassVisitor {
 
-    private final Set<Type> blueprintTypes = new HashSet<Type>();
-    private final Map<Pair<Type, Method>, MethodNode> blueprintRegistry = new HashMap<Pair<Type, Method>, MethodNode>();
+    private final Set<Type> blueprintTypes = new HashSet<>();
+    private final Map<Pair<Type, Method>, MethodNode> blueprintRegistry = new HashMap<>();
 
-    private final Map<Pair<Type, Method>, String> importedMethods = new HashMap<Pair<Type, Method>, String>();
+    private final Map<Pair<Type, Method>, String> importedMethods = new HashMap<>();
 
-    private final Map<Type, Map<Method, MethodNode>> methodCache = new HashMap<Type, Map<Method, MethodNode>>();
-    private final Map<Pair<Type, String>, FieldAccess> fieldAccessMap = new HashMap<Pair<Type, String>, FieldAccess>();
+    private final Map<Type, Map<Method, MethodNode>> methodCache = new HashMap<>();
+    private final Map<Pair<Type, String>, FieldAccess> fieldAccessMap = new HashMap<>();
 
-    private final ClassVisitor next;
+    private final ClassVisitor nextVisitor;
 
     /**
      * Create a new {@link BlueprintingVisitor}.
      * @param privilizer owner
-     * @param next wrapped
+     * @param nextVisitor wrapped
      * @param config annotation
      */
     BlueprintingVisitor(@SuppressWarnings("PMD.UnusedFormalParameter") final Privilizer privilizer, //false positive
-        final ClassVisitor next,
+        final ClassVisitor nextVisitor,
         final Privilizing config) {
         privilizer.super(new ClassNode(Opcodes.ASM5));
-        this.next = next;
+        this.nextVisitor = nextVisitor;
 
         // load up blueprint methods:
         for (final Privilizing.CallTo callTo : config.value()) {
@@ -104,9 +103,8 @@ class BlueprintingVisitor extends Privilizer.PrivilizerClassVisitor {
             return methodCache.get(type);
         }
         final ClassNode classNode = read(type.getClassName());
-        final Map<Method, MethodNode> result = new HashMap<Method, MethodNode>();
+        final Map<Method, MethodNode> result = new HashMap<>();
 
-        @SuppressWarnings("unchecked")
         final List<MethodNode> methods = classNode.methods;
 
         for (final MethodNode methodNode : methods) {
@@ -120,14 +118,10 @@ class BlueprintingVisitor extends Privilizer.PrivilizerClassVisitor {
 
     private ClassNode read(final String className) {
         final ClassNode result = new ClassNode(Opcodes.ASM5);
-        InputStream bytecode = null;
-        try {
-            bytecode = privilizer().env.getClassfile(className).getInputStream();
+        try (InputStream bytecode = privilizer().env.getClassfile(className).getInputStream();) {
             new ClassReader(bytecode).accept(result, ClassReader.SKIP_DEBUG | ClassReader.EXPAND_FRAMES);
         } catch (final Exception e) {
             throw new RuntimeException(e);
-        } finally {
-            IOUtils.closeQuietly(bytecode);
         }
         return result;
     }
@@ -168,10 +162,10 @@ class BlueprintingVisitor extends Privilizer.PrivilizerClassVisitor {
         final MethodNode source = getMethods(key.getLeft()).get(key.getRight());
 
         @SuppressWarnings("unchecked")
-        final String[] exceptions = (String[]) source.exceptions.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
+        final String[] exceptions = ((List<String>) source.exceptions).toArray(ArrayUtils.EMPTY_STRING_ARRAY);
 
         // non-public fields accessed
-        final Set<FieldAccess> fieldAccesses = new LinkedHashSet<FieldAccess>();
+        final Set<FieldAccess> fieldAccesses = new LinkedHashSet<>();
 
         source.accept(new MethodVisitor(Opcodes.ASM5) {
             @Override
@@ -192,17 +186,14 @@ class BlueprintingVisitor extends Privilizer.PrivilizerClassVisitor {
         MethodVisitor mv = new NestedMethodInvocationHandler(withAccessibleAdvice, key.getLeft()); //NOPMD
 
         if (!fieldAccesses.isEmpty()) {
-            // accessesNonPublicFields = true;
-            mv = new AccessibleAdvisor(mv, access, result, source.desc, new ArrayList<FieldAccess>(fieldAccesses));
+            mv = new AccessibleAdvisor(mv, access, result, source.desc, new ArrayList<>(fieldAccesses));
         }
-
         source.accept(mv);
 
         // private can only be called by other privileged methods, so no need to mark as privileged
         if (!Modifier.isPrivate(source.access)) {
             withAccessibleAdvice.visitAnnotation(Type.getType(Privileged.class).getDescriptor(), false).visitEnd();
         }
-
         withAccessibleAdvice.accept(this.cv);
 
         return result;
@@ -212,16 +203,15 @@ class BlueprintingVisitor extends Privilizer.PrivilizerClassVisitor {
         final Pair<Type, String> key = Pair.of(owner, name);
         if (!fieldAccessMap.containsKey(key)) {
             try {
-                final MutableObject<Type> next = new MutableObject<Type>(owner);
-                final Deque<Type> stk = new ArrayDeque<Type>();
+                final MutableObject<Type> next = new MutableObject<>(owner);
+                final Deque<Type> stk = new ArrayDeque<>();
                 while (next.getValue() != null) {
                     stk.push(next.getValue());
-                    InputStream bytecode = null;
-                    try {
-                        bytecode = privilizer().env.getClassfile(next.getValue().getInternalName()).getInputStream();
+                    try (InputStream bytecode =
+                        privilizer().env.getClassfile(next.getValue().getInternalName()).getInputStream()) {
                         new ClassReader(bytecode).accept(privilizer().new PrivilizerClassVisitor() {
                             @Override
-                            @SuppressWarnings("PMD.UseVarargs") //overridden method
+                            @SuppressWarnings("PMD.UseVarargs") // overridden method
                             public void visit(final int version, final int access, final String name,
                                 final String signature, final String superName, final String[] interfaces) {
                                 super.visit(version, access, name, signature, superName, interfaces);
@@ -242,8 +232,6 @@ class BlueprintingVisitor extends Privilizer.PrivilizerClassVisitor {
                                 return null;
                             }
                         }, ClassReader.SKIP_CODE);
-                    } finally {
-                        IOUtils.closeQuietly(bytecode);
                     }
                     if (fieldAccessMap.containsKey(key)) {
                         break;
@@ -260,7 +248,7 @@ class BlueprintingVisitor extends Privilizer.PrivilizerClassVisitor {
     @Override
     public void visitEnd() {
         super.visitEnd();
-        ((ClassNode) cv).accept(next);
+        ((ClassNode) cv).accept(nextVisitor);
     }
 
     private abstract class MethodInvocationHandler extends MethodVisitor {
diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Field.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Field.java
index afa5915..8f9965e 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Field.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Field.java
@@ -18,7 +18,8 @@
  */
 package org.apache.commons.weaver.privilizer;
 
-import org.apache.commons.lang3.ObjectUtils;
+import java.util.Objects;
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.Validate;
 import org.objectweb.asm.Type;
@@ -60,7 +61,6 @@ public class Field {
      * @param obj to check for equality
      * @return whether equal
      */
-    @SuppressWarnings("deprecation")
     @Override
     public boolean equals(final Object obj) {
         if (obj == this) {
@@ -70,7 +70,7 @@ public class Field {
             return false;
         }
         final Field other = (Field) obj;
-        return StringUtils.equals(other.name, name) && ObjectUtils.equals(other.type, type);
+        return StringUtils.equals(other.name, name) && Objects.equals(other.type, type);
     }
 
     /**
@@ -79,10 +79,6 @@ public class Field {
      */
     @Override
     public int hashCode() {
-        int result = 57 << 2;
-        result |= name.hashCode();
-        result <<= 4;
-        result |= type.hashCode();
-        return result;
+        return Objects.hash(name, type);
     }
 }
diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/FieldAccess.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/FieldAccess.java
index ba5554c..cc1542e 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/FieldAccess.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/FieldAccess.java
@@ -67,5 +67,4 @@ public class FieldAccess extends Field {
         final int result = super.hashCode() << 4;
         return result | owner.hashCode();
     }
-
 }
diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Policy.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Policy.java
index cef9344..762e1d9 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Policy.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Policy.java
@@ -75,5 +75,4 @@ public enum Policy {
     public boolean isConditional() {
         return this == ON_INIT || this == DYNAMIC;
     }
-
 }
\ No newline at end of file
diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
index ffa839b..d1e7ab4 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
@@ -110,17 +110,12 @@ public class Privilizer {
             if (verify) {
                 verify(className, bytecode);
             }
-
             final DataSource classfile = env.getClassfile(className);
             env.debug("Writing class %s to resource %s", className, classfile.getName());
-            OutputStream outputStream = null;
-            try {
-                outputStream = classfile.getOutputStream();
+            try (OutputStream outputStream = classfile.getOutputStream()) {
                 IOUtils.write(bytecode, outputStream);
             } catch (final IOException e) {
                 throw new RuntimeException(e);
-            } finally {
-                IOUtils.closeQuietly(outputStream);
             }
         }
     }
@@ -201,9 +196,7 @@ public class Privilizer {
     void blueprint(final Class<?> type, final Privilizing privilizing) {
         final Object[] args = { type.getName(), privilizing };
         env.debug("blueprinting class %s %s", args);
-        InputStream bytecode = null;
-        try {
-            bytecode = env.getClassfile(type).getInputStream();
+        try (InputStream bytecode = env.getClassfile(type).getInputStream()) {
             final ClassReader classReader = new ClassReader(bytecode);
 
             ClassVisitor cvr;
@@ -214,27 +207,21 @@ public class Privilizer {
             classReader.accept(cvr, ClassReader.EXPAND_FRAMES);
         } catch (final Exception e) {
             throw new RuntimeException(e);
-        } finally {
-            IOUtils.closeQuietly(bytecode);
         }
     }
 
     void privilize(final Class<?> type) {
         final Object[] args = { type.getName() };
         env.debug("privilizing class %s", args);
-        InputStream bytecode = null;
-        try {
-            bytecode = env.getClassfile(type).getInputStream();
+        try (InputStream bytecode = env.getClassfile(type).getInputStream()) {
             final ClassReader classReader = new ClassReader(bytecode);
-            ClassVisitor cv; //NOPMD
+            ClassVisitor cv; // NOPMD
             cv = new WriteClass(classReader, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
             cv = new PrivilizingVisitor(this, cv);
 
             classReader.accept(cv, ClassReader.EXPAND_FRAMES);
         } catch (final Exception e) {
             throw new RuntimeException(e);
-        } finally {
-            IOUtils.closeQuietly(bytecode);
         }
     }
 
@@ -255,7 +242,7 @@ public class Privilizer {
         Validate.validState(StringUtils.isBlank(error), error);
 
         final ClassVisitor checkInnerClasses = new ClassVisitor(Opcodes.ASM5, null) {
-            final Set<String> innerNames = new HashSet<String>();
+            final Set<String> innerNames = new HashSet<>();
 
             @Override
             public void visitInnerClass(final String name, final String outerName, final String innerName,
diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerCleaner.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerCleaner.java
index 1f6c799..4c45ffa 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerCleaner.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerCleaner.java
@@ -23,7 +23,6 @@ import java.lang.annotation.ElementType;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.commons.weaver.model.ScanRequest;
 import org.apache.commons.weaver.model.Scanner;
 import org.apache.commons.weaver.model.WeavableClass;
@@ -43,7 +42,7 @@ public class PrivilizerCleaner implements Cleaner {
     public boolean clean(final WeaveEnvironment environment, final Scanner scanner) {
         final Privilizer privilizer = new Privilizer(environment);
 
-        final List<String> toDelete = new ArrayList<String>();
+        final List<String> toDelete = new ArrayList<>();
 
         final ScanRequest scanRequest = new ScanRequest().add(WeaveInterest.of(Privilized.class, ElementType.TYPE));
 
@@ -56,13 +55,11 @@ public class PrivilizerCleaner implements Cleaner {
             final String className = weavableClass.getTarget().getName();
             environment.debug("Class %s privilized with %s; deleting.", className, privilizedPolicy);
 
-            InputStream bytecode = null;
-            try {
-                bytecode = privilizer.env.getClassfile(className).getInputStream();
+            try (InputStream bytecode = privilizer.env.getClassfile(className).getInputStream()) {
                 final ClassReader classReader = new ClassReader(bytecode);
                 classReader.accept(new ClassVisitor(Opcodes.ASM5) {
                     @Override
-                    @SuppressWarnings("PMD.UseVarargs") //overridden method
+                    @SuppressWarnings("PMD.UseVarargs") // overridden method
                     public void visit(final int version, final int access, final String name, final String signature,
                         final String superName, final String[] interfaces) {
                         toDelete.add(name);
@@ -78,8 +75,6 @@ public class PrivilizerCleaner implements Cleaner {
                 }, ClassReader.SKIP_CODE + ClassReader.SKIP_DEBUG + ClassReader.SKIP_FRAMES);
             } catch (final Exception e) {
                 throw new RuntimeException(e);
-            } finally {
-                IOUtils.closeQuietly(bytecode);
             }
         }
         boolean result = false;
diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerWeaver.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerWeaver.java
index e7e7149..44e53bb 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerWeaver.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerWeaver.java
@@ -38,7 +38,7 @@ public class PrivilizerWeaver implements Weaver {
     public boolean process(final WeaveEnvironment weaveEnvironment, final Scanner scanner) {
         final Privilizer privilizer = new Privilizer(weaveEnvironment);
 
-        final Set<Class<?>> privilizedTypes = new LinkedHashSet<Class<?>>();
+        final Set<Class<?>> privilizedTypes = new LinkedHashSet<>();
 
         // handle blueprints:
         for (final WeavableClass<?> type : scanner.scan(
diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizingVisitor.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizingVisitor.java
index ec4374c..8d4c1a5 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizingVisitor.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizingVisitor.java
@@ -42,7 +42,7 @@ import org.objectweb.asm.commons.StaticInitMerger;
  * ASM {@link ClassVisitor} to privilize {@link Privileged} methods.
  */
 class PrivilizingVisitor extends Privilizer.PrivilizerClassVisitor {
-    final Map<Method, String> privilegedMethods = new LinkedHashMap<Method, String>();
+    final Map<Method, String> privilegedMethods = new LinkedHashMap<>();
     boolean annotated;
     final Policy policy;
     final AccessLevel accessLevel;
@@ -148,7 +148,6 @@ class PrivilizingVisitor extends Privilizer.PrivilizerClassVisitor {
                 } else {
                     privilizer().env.debug("setting up unconditional privileged execution due to policy %s", policy);
                 }
-
                 // generate action:
                 final Type[] ctorArgs;
                 if (instanceMethod) {
@@ -190,7 +189,6 @@ class PrivilizingVisitor extends Privilizer.PrivilizerClassVisitor {
                     // throw
                     throwException();
                 }
-
                 // end original method
                 endMethod();
 
@@ -199,7 +197,6 @@ class PrivilizingVisitor extends Privilizer.PrivilizerClassVisitor {
                 mv.visitCode();
             }
         };
-
     }
 
     @Override
diff --git a/pom.xml b/pom.xml
index 0503308..c3bf4cc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -61,8 +61,8 @@ under the License.
 
     <!-- most Java-related items are defined in parent/pom.xml;
          define these here for the animal-sniffer config of commons-parent: -->
-    <maven.compiler.source>1.6</maven.compiler.source>
-    <maven.compiler.target>1.6</maven.compiler.target>
+    <maven.compiler.source>1.8</maven.compiler.source>
+    <maven.compiler.target>1.8</maven.compiler.target>
 
     <ant.version>1.9.4</ant.version>
     <asm.version>5.1</asm.version>
@@ -119,6 +119,11 @@ under the License.
           </configuration>
         </plugin>
         <plugin>
+	        <groupId>org.apache.maven.plugins</groupId>
+	        <artifactId>maven-shade-plugin</artifactId>
+	        <version>3.1.1</version>
+        </plugin>
+        <plugin>
           <groupId>org.apache.rat</groupId>
           <artifactId>apache-rat-plugin</artifactId>
           <configuration>
diff --git a/processor/src/main/java/org/apache/commons/weaver/CleanProcessor.java b/processor/src/main/java/org/apache/commons/weaver/CleanProcessor.java
index af4004d..0f9ad99 100644
--- a/processor/src/main/java/org/apache/commons/weaver/CleanProcessor.java
+++ b/processor/src/main/java/org/apache/commons/weaver/CleanProcessor.java
@@ -62,7 +62,7 @@ public class CleanProcessor extends ProcessorBase<Cleaner> {
      */
     public void clean() {
         if (!target.exists()) {
-            log.warning("Target directory " + target + " does not exist; nothing to do!");
+            log.warning(() -> String.format("Target directory %s does not exist; nothing to do!", target));
         }
         for (final Cleaner cleaner : providers) {
             final WeaveEnvironment env = new LocalWeaveEnvironment(target, classLoader, configuration,
diff --git a/processor/src/main/java/org/apache/commons/weaver/Finder.java b/processor/src/main/java/org/apache/commons/weaver/Finder.java
index f86d60a..548998e 100644
--- a/processor/src/main/java/org/apache/commons/weaver/Finder.java
+++ b/processor/src/main/java/org/apache/commons/weaver/Finder.java
@@ -33,9 +33,13 @@ import java.util.IdentityHashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.collections4.Predicate;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.Validate;
@@ -63,7 +67,7 @@ class Finder extends AnnotationFinder implements Scanner {
 
     private abstract class AnnotationInflater extends AnnotationCapturer {
         final Class<? extends Annotation> annotationType;
-        final Map<String, Object> elements = new LinkedHashMap<String, Object>();
+        final Map<String, Object> elements = new LinkedHashMap<>();
 
         AnnotationInflater(final String desc, final AnnotationVisitor wrapped) {
             super(wrapped);
@@ -136,7 +140,7 @@ class Finder extends AnnotationFinder implements Scanner {
         @Override
         public AnnotationVisitor visitArray(final String name) {
             final AnnotationCapturer owner = this;
-            final List<Object> values = new ArrayList<Object>();
+            final List<Object> values = new ArrayList<>();
             return new AnnotationCapturer(super.visitArray(name)) {
 
                 @Override
@@ -180,18 +184,7 @@ class Finder extends AnnotationFinder implements Scanner {
         @Override
         public void visitEnd() {
             super.visitEnd();
-            classfileAnnotationsFor(info).add(inflate());
-        }
-
-        private List<Annotation> classfileAnnotationsFor(final Info info) {
-            synchronized (CLASSFILE_ANNOTATIONS) {
-                if (!CLASSFILE_ANNOTATIONS.get().containsKey(info)) {
-                    final List<Annotation> result = new ArrayList<Annotation>();
-                    CLASSFILE_ANNOTATIONS.get().put(info, result);
-                    return result;
-                }
-            }
-            return CLASSFILE_ANNOTATIONS.get().get(info);
+            CLASSFILE_ANNOTATIONS.get().computeIfAbsent(info, k -> new ArrayList<>()).add(inflate());
         }
     }
 
@@ -361,36 +354,25 @@ class Finder extends AnnotationFinder implements Scanner {
         public T get() {
             return target;
         }
-
     }
 
     /**
      * Helper class for finding elements with annotations (including those with classfile-level retention).
      */
     public final class WithAnnotations {
-        private static final String INIT = "<init>";
-
         private WithAnnotations() {
         }
 
         public List<Annotated<Package>> findAnnotatedPackages(final Class<? extends Annotation> annotation) {
             Finder.this.findAnnotatedPackages(annotation);
-            final List<Annotated<Package>> result = new ArrayList<Annotated<Package>>();
-            for (final Info info : getAnnotationInfos(annotation.getName())) {
-                if (info instanceof PackageInfo) {
-                    final PackageInfo packageInfo = (PackageInfo) info;
-                    try {
-                        final IncludesClassfile<Package> annotated =
-                            new IncludesClassfile<Package>(packageInfo.get(), classfileAnnotationsFor(packageInfo));
-                        if (annotated.isAnnotationPresent(annotation)) {
-                            result.add(annotated);
-                        }
-                    } catch (final ClassNotFoundException e) {
-                        continue;
-                    }
+
+            return typed(PackageInfo.class, getAnnotationInfos(annotation.getName())::stream).map(packageInfo -> {
+                try {
+                    return new IncludesClassfile<>(packageInfo.get(), classfileAnnotationsFor(packageInfo));
+                } catch (ClassNotFoundException e) {
+                    return null;
                 }
-            }
-            return result;
+            }).filter(hasAnnotation(annotation)).collect(Collectors.toList());
         }
 
         /**
@@ -405,212 +387,138 @@ class Finder extends AnnotationFinder implements Scanner {
         public List<Annotated<Class<?>>> findAnnotatedClasses(final Class<? extends Annotation> annotation) {
             Finder.this.findAnnotatedClasses(annotation);
 
-            final List<Annotated<Class<?>>> annotatedClasses = annotate(getAnnotationInfos(annotation.getName()));
-            CollectionUtils.filter(annotatedClasses, new Predicate<Annotated<Class<?>>>() {
-
-                @Override
-                public boolean evaluate(final Annotated<Class<?>> annotatedClass) {
-                    return annotatedClass.isAnnotationPresent(annotation);
-                }
-            });
-            return annotatedClasses;
+            return annotate(getAnnotationInfos(annotation.getName())).stream().filter(hasAnnotation(annotation))
+                .collect(Collectors.toList());
         }
 
         private List<Annotated<Class<?>>> annotate(final Collection<? extends Info> infos) {
-            final List<Annotated<Class<?>>> result = new ArrayList<Annotated<Class<?>>>();
-            for (final Info info : infos) {
-                if (info instanceof ClassInfo) {
-                    final ClassInfo classInfo = (ClassInfo) info;
-
-                    try {
-                        result
-                            .add(new IncludesClassfile<Class<?>>(classInfo.get(), classfileAnnotationsFor(classInfo)));
-                    } catch (final ClassNotFoundException e) {
-                        continue;
-                    }
+            return typed(ClassInfo.class, infos::stream).map(classInfo -> {
+                try {
+                    return new IncludesClassfile<Class<?>>(classInfo.get(), classfileAnnotationsFor(classInfo));
+                } catch (ClassNotFoundException e1) {
+                    return null;
                 }
-            }
-            return result;
+            }).filter(Objects::nonNull).collect(Collectors.toList());
         }
 
         public List<Annotated<Class<?>>> findAssignableTypes(final Class<?> supertype) {
-            final List<Annotated<Class<?>>> result = new ArrayList<Annotated<Class<?>>>();
-            final List<?> assignableTypes;
-            if (supertype.isInterface()) {
-                assignableTypes = Finder.this.findImplementations(supertype);
-            } else {
-                assignableTypes = Finder.this.findSubclasses(supertype);
-            }
+            @SuppressWarnings({ "unchecked", "rawtypes" })
+            final List<Class<?>> assignableTypes = (List) (supertype.isInterface()
+                ? Finder.this.findImplementations(supertype) : Finder.this.findSubclasses(supertype));
 
-            for (final Object object : assignableTypes) {
-                final ClassInfo classInfo = classInfos.get(((Class<?>) object).getName());
-                final IncludesClassfile<Class<?>> annotated;
-                try {
-                    annotated = new IncludesClassfile<Class<?>>(classInfo.get(), classfileAnnotationsFor(classInfo));
-                } catch (final ClassNotFoundException e) {
-                    continue;
-                }
-                result.add(annotated);
-            }
-            return result;
+            return assignableTypes.stream().map(Class::getName).map(classInfos::get)
+                .<IncludesClassfile<Class<?>>> map(classInfo -> {
+                    try {
+                        return new IncludesClassfile<>(classInfo.get(), classfileAnnotationsFor(classInfo));
+                    } catch (final ClassNotFoundException e) {
+                        return null;
+                    }
+                }).filter(Objects::nonNull).collect(Collectors.toList());
         }
 
         public List<Annotated<Method>> findAnnotatedMethods(final Class<? extends Annotation> annotation) {
             Finder.this.findAnnotatedMethods(annotation);
-            final List<Annotated<Method>> result = new ArrayList<Annotated<Method>>();
-            for (final Info info : getAnnotationInfos(annotation.getName())) {
-                if (info instanceof MethodInfo) {
-                    final MethodInfo methodInfo = (MethodInfo) info;
-                    if (INIT.equals(methodInfo.getName())) {
-                        continue;
-                    }
-                    IncludesClassfile<Method> annotated;
+
+            return typed(MethodInfo.class, getAnnotationInfos(annotation.getName())::stream).filter(CTOR.negate())
+                .map(methodInfo -> {
                     try {
-                        annotated =
-                            new IncludesClassfile<Method>((Method) methodInfo.get(),
-                                classfileAnnotationsFor(methodInfo));
+                        return new IncludesClassfile<>((Method) methodInfo.get(),
+                            classfileAnnotationsFor(methodInfo));
                     } catch (final ClassNotFoundException e) {
-                        continue;
+                        return null;
                     }
-                    if (annotated.isAnnotationPresent(annotation)) {
-                        result.add(annotated);
-                    }
-                }
-            }
-            return result;
-
+                }).filter(hasAnnotation(annotation)).collect(Collectors.toList());
         }
 
         public List<Annotated<Parameter<Method>>> findAnnotatedMethodParameters(
             final Class<? extends Annotation> annotationType) {
             Finder.this.findAnnotatedMethodParameters(annotationType);
-            final List<Annotated<Parameter<Method>>> result = new ArrayList<Annotated<Parameter<Method>>>();
-            for (final Info info : getAnnotationInfos(annotationType.getName())) {
-                if (info instanceof ParameterInfo) {
-                    final ParameterInfo parameterInfo = (ParameterInfo) info;
-                    if (INIT.equals(parameterInfo.getDeclaringMethod().getName())) {
-                        continue;
-                    }
-                    Parameter<Method> parameter;
+
+            return typed(ParameterInfo.class, getAnnotationInfos(annotationType.getName())::stream)
+                .filter(isCtor(ParameterInfo::getDeclaringMethod).negate()).map(parameterInfo -> {
                     try {
                         @SuppressWarnings("unchecked")
-                        final Parameter<Method> unchecked = (Parameter<Method>) parameterInfo.get();
-                        parameter = unchecked;
+                        final Parameter<Method> parameter = (Parameter<Method>) parameterInfo.get();
+                        return new IncludesClassfile<>(parameter, classfileAnnotationsFor(parameterInfo));
                     } catch (final ClassNotFoundException e) {
-                        continue;
-                    }
-                    final IncludesClassfile<Parameter<Method>> annotated =
-                        new IncludesClassfile<Parameter<Method>>(parameter, classfileAnnotationsFor(parameterInfo));
-                    if (annotated.isAnnotationPresent(annotationType)) {
-                        result.add(annotated);
+                        return null;
                     }
-                }
-            }
-            return result;
+                }).filter(hasAnnotation(annotationType)).collect(Collectors.toList());
         }
 
         public List<Annotated<Constructor<?>>> findAnnotatedConstructors(final Class<? extends Annotation> annotation) {
             Finder.this.findAnnotatedConstructors(annotation);
-            final List<Annotated<Constructor<?>>> result = new ArrayList<Annotated<Constructor<?>>>();
-            for (final Info info : getAnnotationInfos(annotation.getName())) {
-                if (info instanceof MethodInfo) {
-                    final MethodInfo methodInfo = (MethodInfo) info;
-                    if (!INIT.equals(methodInfo.getName())) {
-                        continue;
-                    }
-                    final IncludesClassfile<Constructor<?>> annotated;
+
+            return typed(MethodInfo.class, getAnnotationInfos(annotation.getName())::stream).filter(CTOR)
+                .map(methodInfo -> {
                     try {
-                        annotated =
-                            new IncludesClassfile<Constructor<?>>((Constructor<?>) methodInfo.get(),
-                                classfileAnnotationsFor(methodInfo));
+                        final IncludesClassfile<Constructor<?>> annotated = new IncludesClassfile<>(
+                            (Constructor<?>) methodInfo.get(), classfileAnnotationsFor(methodInfo));
+                        return annotated;
                     } catch (final ClassNotFoundException e) {
-                        continue;
-                    }
-                    if (annotated.isAnnotationPresent(annotation)) {
-                        result.add(annotated);
+                        return null;
                     }
-                }
-            }
-            return result;
+                }).filter(hasAnnotation(annotation)).collect(Collectors.toList());
         }
 
         public List<Annotated<Parameter<Constructor<?>>>> findAnnotatedConstructorParameters(
             final Class<? extends Annotation> annotation) {
             Finder.this.findAnnotatedConstructorParameters(annotation);
-            final List<Annotated<Parameter<Constructor<?>>>> result =
-                new ArrayList<Annotated<Parameter<Constructor<?>>>>();
-            for (final Info info : getAnnotationInfos(annotation.getName())) {
-                if (info instanceof ParameterInfo) {
-                    final ParameterInfo parameterInfo = (ParameterInfo) info;
-                    if (!INIT.equals(parameterInfo.getDeclaringMethod().getName())) {
-                        continue;
-                    }
-                    Parameter<Constructor<?>> parameter;
+
+            return typed(ParameterInfo.class, getAnnotationInfos(annotation.getName())::stream)
+                .filter(isCtor(ParameterInfo::getDeclaringMethod)).map(parameterInfo -> {
                     try {
                         @SuppressWarnings("unchecked")
-                        final Parameter<Constructor<?>> unchecked = (Parameter<Constructor<?>>) parameterInfo.get();
-                        parameter = unchecked;
+                        final Parameter<Constructor<?>> parameter = (Parameter<Constructor<?>>) parameterInfo.get();
+                        return new IncludesClassfile<>(parameter, classfileAnnotationsFor(parameterInfo));
                     } catch (final ClassNotFoundException e) {
-                        continue;
+                        return null;
                     }
-                    final IncludesClassfile<Parameter<Constructor<?>>> annotated =
-                        new IncludesClassfile<Parameter<Constructor<?>>>(parameter,
-                            classfileAnnotationsFor(parameterInfo));
-                    if (annotated.isAnnotationPresent(annotation)) {
-                        result.add(annotated);
-                    }
-                }
-            }
-            return result;
+                }).filter(hasAnnotation(annotation)).collect(Collectors.toList());
         }
 
         public List<Annotated<Field>> findAnnotatedFields(final Class<? extends Annotation> annotation) {
             Finder.this.findAnnotatedFields(annotation);
-            final List<Annotated<Field>> result = new ArrayList<Annotated<Field>>();
-            for (final Info info : getAnnotationInfos(annotation.getName())) {
-                if (info instanceof FieldInfo) {
-                    final FieldInfo fieldInfo = (FieldInfo) info;
-                    try {
-                        final IncludesClassfile<Field> annotated =
-                            new IncludesClassfile<Field>((Field) fieldInfo.get(), classfileAnnotationsFor(fieldInfo));
-                        if (annotated.isAnnotationPresent(annotation)) {
-                            result.add(annotated);
-                        }
-                    } catch (final ClassNotFoundException e) {
-                        continue;
-                    }
+
+            return typed(FieldInfo.class, getAnnotationInfos(annotation.getName())::stream).map(fieldInfo -> {
+                try {
+                    return new IncludesClassfile<>((Field) fieldInfo.get(), classfileAnnotationsFor(fieldInfo));
+                } catch (final ClassNotFoundException e) {
+                    return null;
                 }
-            }
-            return result;
+            }).filter(hasAnnotation(annotation)).collect(Collectors.toList());
         }
 
         private List<Annotation> classfileAnnotationsFor(final Info info) {
-            synchronized (classfileAnnotations) {
-                if (!classfileAnnotations.containsKey(info)) {
-                    final List<Annotation> result = new ArrayList<Annotation>();
-                    classfileAnnotations.put(info, result);
-                    return result;
-                }
-            }
-            return classfileAnnotations.get(info);
+            return classfileAnnotations.computeIfAbsent(info, k -> new ArrayList<>());
         }
-
     }
 
     private static final int ASM_FLAGS = ClassReader.SKIP_CODE + ClassReader.SKIP_DEBUG + ClassReader.SKIP_FRAMES;
 
+    private static final String INIT = "<init>";
+
+    private static final Predicate<MethodInfo> CTOR = methodInfo -> INIT.equals(methodInfo.getName());
+
     /**
      * The {@link #classfileAnnotations} member stores these; however the scanning takes place in the scope of the super
      * constructor call, thus there is no opportunity to set the reference beforehand. To work around this, we use a
      * static ThreadLocal with an initializer and pull/clear its value when we return from the super constructor. :P
      */
     private static final ThreadLocal<Map<Info, List<Annotation>>> CLASSFILE_ANNOTATIONS =
-        new ThreadLocal<Map<Info, List<Annotation>>>() {
-            @Override
-            protected Map<Info, List<Annotation>> initialValue() {
-                return new IdentityHashMap<AnnotationFinder.Info, List<Annotation>>();
-            }
-        };
+        ThreadLocal.withInitial(IdentityHashMap::new);
+
+    private static <T, U> Stream<U> typed(Class<U> type, Supplier<Stream<T>> stream) {
+        return stream.get().filter(type::isInstance).map(type::cast);
+    }
+
+    private static Predicate<Annotated<?>> hasAnnotation(Class<? extends Annotation> annotation) {
+        return annotated -> annotated != null && annotated.isAnnotationPresent(annotation);
+    }
+
+    private static <T> Predicate<T> isCtor(Function<? super T, MethodInfo> xform) {
+        return t -> CTOR.test(xform.apply(t));
+    }
 
     private final WithAnnotations withAnnotations = new WithAnnotations();
     private final Map<Info, List<Annotation>> classfileAnnotations;
@@ -643,8 +551,7 @@ class Finder extends AnnotationFinder implements Scanner {
     @Override
     protected void readClassDef(final InputStream bytecode) throws IOException {
         try {
-            final ClassReader classReader = new ClassReader(bytecode);
-            classReader.accept(new Visitor(new InfoBuildingVisitor()), ASM_FLAGS);
+            new ClassReader(bytecode).accept(new Visitor(new InfoBuildingVisitor()), ASM_FLAGS);
         } finally {
             bytecode.close();
         }
@@ -737,11 +644,9 @@ class Finder extends AnnotationFinder implements Scanner {
                     break;
                 }
             }
-            for (final Class<?> supertype : request.getSupertypes()) {
-                for (final Annotated<Class<?>> type : this.withAnnotations().findAssignableTypes(supertype)) {
-                    result.getWeavable(type.get()).addAnnotations(type.getAnnotations());
-                }
-            }
+            request.getSupertypes().stream().map(this.withAnnotations()::findAssignableTypes)
+                .flatMap(Collection::stream)
+                .forEach(type -> result.getWeavable(type.get()).addAnnotations(type.getAnnotations()));
         }
         return inflater.inflate(result);
     }
diff --git a/processor/src/main/java/org/apache/commons/weaver/Inflater.java b/processor/src/main/java/org/apache/commons/weaver/Inflater.java
index 0b1dae4..c5b6137 100644
--- a/processor/src/main/java/org/apache/commons/weaver/Inflater.java
+++ b/processor/src/main/java/org/apache/commons/weaver/Inflater.java
@@ -19,9 +19,10 @@
 package org.apache.commons.weaver;
 
 import java.lang.annotation.Annotation;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
 
 import org.apache.commons.weaver.model.ScanResult;
 import org.apache.commons.weaver.model.WeavableClass;
@@ -43,7 +44,7 @@ import org.apache.xbean.finder.Parameter;
  * Adds all classfile annotations to a ScanResult.
  */
 class Inflater {
-    private class InfoMatcher {
+    private class InfoMatcher implements Predicate<Info> {
         final Class<? extends Info> type;
 
         InfoMatcher(final Class<? extends Info> type) {
@@ -51,10 +52,9 @@ class Inflater {
             this.type = type;
         }
 
-        boolean test(final Info info) {
+        public boolean test(final Info info) {
             return type.isInstance(info);
         }
-
     }
 
     private class MethodMatcher extends InfoMatcher {
@@ -66,7 +66,7 @@ class Inflater {
         }
 
         @Override
-        boolean test(final Info info) {
+        public boolean test(final Info info) {
             return super.test(info) && ((MethodInfo) info).isConstructor() == isCtor;
         }
     }
@@ -80,7 +80,7 @@ class Inflater {
         }
 
         @Override
-        boolean test(final Info info) {
+        public boolean test(final Info info) {
             return super.test(info) && ((ParameterInfo) info).getDeclaringMethod().isConstructor() == isCtor;
         }
     }
@@ -107,94 +107,82 @@ class Inflater {
 
     static <I extends Info> Map<I, List<Annotation>> subMap(final Map<Info, List<Annotation>> source,
         final InfoMatcher matcher) {
-        final HashMap<I, List<Annotation>> result = new HashMap<I, List<Annotation>>();
-        for (final Map.Entry<Info, List<Annotation>> entry : source.entrySet()) {
-            if (matcher.test(entry.getKey())) {
-                @SuppressWarnings("unchecked")
-                final I key = (I) entry.getKey();
-                result.put(key, entry.getValue());
-            }
-        }
+        @SuppressWarnings("unchecked")
+        final Map<I, List<Annotation>> result = source.entrySet().stream().filter(e -> matcher.test(e.getKey()))
+            .collect(Collectors.toMap(t -> (I) t.getKey(), Map.Entry::getValue));
+
         return result;
     }
 
     ScanResult inflate(final ScanResult scanResult) {
         for (final WeavablePackage pkg : scanResult.getPackages()) {
-            for (final Map.Entry<PackageInfo, List<Annotation>> entry : packageAnnotations.entrySet()) {
-                if (entry.getKey().getName().equals(pkg.getTarget().getName())) {
-                    pkg.addAnnotations(entry.getValue());
+            packageAnnotations.forEach((k, v) -> {
+                if (k.getName().equals(pkg.getTarget().getName())) {
+                    pkg.addAnnotations(v);
                 }
-            }
+            });
             for (final WeavableClass<?> cls : pkg.getClasses()) {
-                for (final Map.Entry<ClassInfo, List<Annotation>> entry : classAnnotations.entrySet()) {
-                    if (entry.getKey().getName().equals(cls.getTarget().getName())) {
-                        cls.addAnnotations(entry.getValue());
+                classAnnotations.forEach((k, v) -> {
+                    if (k.getName().equals(cls.getTarget().getName())) {
+                        cls.addAnnotations(v);
                     }
-                }
+                });
                 for (final WeavableField<?> fld : cls.getFields()) {
-                    for (final Map.Entry<FieldInfo, List<Annotation>> entry : fieldAnnotations.entrySet()) {
+                    fieldAnnotations.forEach((k, v) -> {
                         try {
-                            if (entry.getKey().get().equals(fld.getTarget())) {
-                                fld.addAnnotations(entry.getValue());
+                            if (k.get().equals(fld.getTarget())) {
+                                fld.addAnnotations(v);
                             }
                         } catch (final ClassNotFoundException cnfe) {
-                            continue;
                         }
-                    }
+                    });
                 }
                 for (final WeavableConstructor<?> ctor : cls.getConstructors()) {
-                    for (final Map.Entry<MethodInfo, List<Annotation>> entry : ctorAnnotations.entrySet()) {
+                    ctorAnnotations.forEach((k, v) -> {
                         try {
-                            if (entry.getKey().get().equals(ctor.getTarget())) {
-                                ctor.addAnnotations(entry.getValue());
+                            if (k.get().equals(ctor.getTarget())) {
+                                ctor.addAnnotations(v);
                             }
                         } catch (final ClassNotFoundException cnfe) {
-                            continue;
                         }
-                    }
+                    });
                     for (final WeavableConstructorParameter<?> param : ctor.getParameters()) {
-                        for (final Map.Entry<ParameterInfo, List<Annotation>> entry : ctorParameterAnnotations
-                            .entrySet()) {
+                        ctorParameterAnnotations.forEach((k, v) -> {
                             try {
-                                final Parameter<?> parameter = entry.getKey().get();
+                                final Parameter<?> parameter = k.get();
                                 if (parameter.getDeclaringExecutable().equals(ctor.getTarget())
                                     && param.getTarget().intValue() == parameter.getIndex()) {
-                                    param.addAnnotations(entry.getValue());
+                                    param.addAnnotations(v);
                                 }
                             } catch (final ClassNotFoundException cnfe) {
-                                continue;
                             }
-                        }
+                        });
                     }
                 }
                 for (final WeavableMethod<?> methd : cls.getMethods()) {
-                    for (final Map.Entry<MethodInfo, List<Annotation>> entry : methodAnnotations.entrySet()) {
+                    methodAnnotations.forEach((k, v) -> {
                         try {
-                            if (entry.getKey().get().equals(methd.getTarget())) {
-                                methd.addAnnotations(entry.getValue());
+                            if (k.get().equals(methd.getTarget())) {
+                                methd.addAnnotations(v);
                             }
                         } catch (final ClassNotFoundException cnfe) {
-                            continue;
                         }
-                    }
+                    });
                     for (final WeavableMethodParameter<?> param : methd.getParameters()) {
-                        for (final Map.Entry<ParameterInfo, List<Annotation>> entry : methodParameterAnnotations
-                            .entrySet()) {
+                        methodParameterAnnotations.forEach((k, v) -> {
                             try {
-                                final Parameter<?> parameter = entry.getKey().get();
+                                final Parameter<?> parameter = k.get();
                                 if (parameter.getDeclaringExecutable().equals(methd.getTarget())
                                     && param.getTarget().intValue() == parameter.getIndex()) {
-                                    param.addAnnotations(entry.getValue());
+                                    param.addAnnotations(v);
                                 }
                             } catch (final ClassNotFoundException cnfe) {
-                                continue;
                             }
-                        }
+                        });
                     }
                 }
             }
         }
         return scanResult;
     }
-
 }
diff --git a/processor/src/main/java/org/apache/commons/weaver/ProcessorBase.java b/processor/src/main/java/org/apache/commons/weaver/ProcessorBase.java
index 1248821..ee449ac 100755
--- a/processor/src/main/java/org/apache/commons/weaver/ProcessorBase.java
+++ b/processor/src/main/java/org/apache/commons/weaver/ProcessorBase.java
@@ -52,7 +52,7 @@ class ProcessorBase<P extends WeaveLifecycleProvider<?>> {
      */
     static <T> Iterable<T> getServiceInstances(final Class<T> type) {
         Validate.notNull(type);
-        final List<T> result = new ArrayList<T>();
+        final List<T> result = new ArrayList<>();
         final ClassLoader typeLoader = type.getClassLoader();
         if (!Thread.currentThread().getContextClassLoader().equals(typeLoader)) {
             for (final T t : ServiceLoader.load(type, typeLoader)) {
@@ -120,7 +120,7 @@ class ProcessorBase<P extends WeaveLifecycleProvider<?>> {
     }
 
     private ClassLoader createClassLoader() {
-        final Set<String> finderClasspath = new LinkedHashSet<String>();
+        final Set<String> finderClasspath = new LinkedHashSet<>();
         finderClasspath.add(target.getAbsolutePath());
         finderClasspath.addAll(classpath);
         return new URLClassLoader(URLArray.fromPaths(finderClasspath));
diff --git a/processor/src/main/java/org/apache/commons/weaver/WeaveProcessor.java b/processor/src/main/java/org/apache/commons/weaver/WeaveProcessor.java
index d77dd93..5624c4e 100644
--- a/processor/src/main/java/org/apache/commons/weaver/WeaveProcessor.java
+++ b/processor/src/main/java/org/apache/commons/weaver/WeaveProcessor.java
@@ -62,7 +62,7 @@ public class WeaveProcessor extends ProcessorBase<Weaver> {
      */
     public void weave() {
         if (!target.exists()) {
-            log.warning("Target directory " + target + " does not exist; nothing to do!");
+            log.warning(() -> String.format("Target directory %s does not exist; nothing to do!", target));
         }
         for (final Weaver weaver : providers) {
             final WeaveEnvironment env = new LocalWeaveEnvironment(target, classLoader, configuration,
diff --git a/processor/src/main/java/org/apache/commons/weaver/model/ScanRequest.java b/processor/src/main/java/org/apache/commons/weaver/model/ScanRequest.java
index 06638b4..1c4cb17 100644
--- a/processor/src/main/java/org/apache/commons/weaver/model/ScanRequest.java
+++ b/processor/src/main/java/org/apache/commons/weaver/model/ScanRequest.java
@@ -35,8 +35,8 @@ import org.apache.commons.weaver.spi.Weaver;
  */
 public class ScanRequest {
 
-    private final List<WeaveInterest> interests = new ArrayList<WeaveInterest>();
-    private final Set<Class<?>> supertypes = new LinkedHashSet<Class<?>>();
+    private final List<WeaveInterest> interests = new ArrayList<>();
+    private final Set<Class<?>> supertypes = new LinkedHashSet<>();
 
     /**
      * Register a {@link WeaveInterest}.
diff --git a/processor/src/main/java/org/apache/commons/weaver/model/ScanResult.java b/processor/src/main/java/org/apache/commons/weaver/model/ScanResult.java
index fdaf892..7f3ce0e 100644
--- a/processor/src/main/java/org/apache/commons/weaver/model/ScanResult.java
+++ b/processor/src/main/java/org/apache/commons/weaver/model/ScanResult.java
@@ -111,7 +111,7 @@ public class ScanResult {
 
         @Override
         public AnnotatedElements<CHILD> with(final Class<? extends Annotation> annotationType) {
-            return new AnnotatedWith<CHILD>(this, annotationType);
+            return new AnnotatedWith<>(this, annotationType);
         }
     }
 
@@ -167,13 +167,13 @@ public class ScanResult {
 
         @Override
         public AnnotatedElements<W> with(final Class<? extends Annotation> annotationType) {
-            return new AnnotatedWith<W>(this, annotationType);
+            return new AnnotatedWith<>(this, annotationType);
         }
 
     }
 
     private final ConcurrentNavigableMap<String, WeavablePackage> packages =
-        new ConcurrentSkipListMap<String, WeavablePackage>();
+        new ConcurrentSkipListMap<>();
 
     /**
      * Public for use by {@link WeaveProcessor}.
@@ -242,7 +242,7 @@ public class ScanResult {
 
             @Override
             public AnnotatedElements<WeavablePackage> with(final Class<? extends Annotation> annotationType) {
-                return new AnnotatedWith<WeavablePackage>(packages.values(), annotationType);
+                return new AnnotatedWith<>(packages.values(), annotationType);
             }
         };
     }
@@ -400,5 +400,4 @@ public class ScanResult {
             }
         };
     }
-
 }
diff --git a/processor/src/main/java/org/apache/commons/weaver/model/Weavable.java b/processor/src/main/java/org/apache/commons/weaver/model/Weavable.java
index fb756ca..37bc4b1 100644
--- a/processor/src/main/java/org/apache/commons/weaver/model/Weavable.java
+++ b/processor/src/main/java/org/apache/commons/weaver/model/Weavable.java
@@ -74,7 +74,7 @@ public abstract class Weavable<SELF extends Weavable<SELF, TARGET>, TARGET> impl
         }
         synchronized (this) {
             if (annotations == null) {
-                annotations = new LinkedHashSet<Annotation>();
+                annotations = new LinkedHashSet<>();
             }
             boolean result = false;
             for (final Annotation ann : toAdd) {
diff --git a/processor/src/main/java/org/apache/commons/weaver/model/WeavableClass.java b/processor/src/main/java/org/apache/commons/weaver/model/WeavableClass.java
index 38f579e..9d78a7a 100644
--- a/processor/src/main/java/org/apache/commons/weaver/model/WeavableClass.java
+++ b/processor/src/main/java/org/apache/commons/weaver/model/WeavableClass.java
@@ -22,7 +22,6 @@ import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.util.Collections;
-import java.util.Comparator;
 import java.util.concurrent.ConcurrentNavigableMap;
 import java.util.concurrent.ConcurrentSkipListMap;
 
@@ -34,26 +33,15 @@ import org.apache.commons.weaver.utils.Args;
  * @param <T> type
  */
 public class WeavableClass<T> extends NestedWeavable<WeavableClass<T>, Class<T>, WeavablePackage, Package> {
-    private final ConcurrentNavigableMap<String, WeavableField<T>> fields =
-        new ConcurrentSkipListMap<String, WeavableField<T>>();
+    private final ConcurrentNavigableMap<String, WeavableField<T>> fields = new ConcurrentSkipListMap<>();
 
-    private final ConcurrentNavigableMap<Constructor<T>, WeavableConstructor<T>> ctors =
-        new ConcurrentSkipListMap<Constructor<T>, WeavableConstructor<T>>(new Comparator<Constructor<?>>() {
-
-            @Override
-            public int compare(final Constructor<?> ctor1, final Constructor<?> ctor2) {
-                return Args.compare(ctor1.getParameterTypes(), ctor2.getParameterTypes());
-            }
-        });
+    private final ConcurrentNavigableMap<Constructor<T>, WeavableConstructor<T>> ctors = new ConcurrentSkipListMap<>(
+        (ctor1, ctor2) -> Args.compare(ctor1.getParameterTypes(), ctor2.getParameterTypes()));
 
     private final ConcurrentNavigableMap<Method, WeavableMethod<T>> methods =
-        new ConcurrentSkipListMap<Method, WeavableMethod<T>>(new Comparator<Method>() {
-
-            @Override
-            public int compare(final Method methd1, final Method methd2) {
-                final int result = methd1.getName().compareTo(methd2.getName());
-                return result == 0 ? Args.compare(methd1.getParameterTypes(), methd2.getParameterTypes()) : result;
-            }
+        new ConcurrentSkipListMap<>((methd1, methd2) -> {
+            final int result = methd1.getName().compareTo(methd2.getName());
+            return result == 0 ? Args.compare(methd1.getParameterTypes(), methd2.getParameterTypes()) : result;
         });
 
     /**
@@ -73,10 +61,9 @@ public class WeavableClass<T> extends NestedWeavable<WeavableClass<T>, Class<T>,
     public WeavableField<T> getWeavable(final Field fld) {
         final String key = fld.getName();
         if (fields.containsKey(key)) {
-            final WeavableField<T> result = fields.get(key);
-            return result;
+            return fields.get(key);
         }
-        final WeavableField<T> result = new WeavableField<T>(fld, this);
+        final WeavableField<T> result = new WeavableField<>(fld, this);
         final WeavableField<T> faster = fields.putIfAbsent(key, result);
         return faster == null ? result : faster;
     }
@@ -88,10 +75,9 @@ public class WeavableClass<T> extends NestedWeavable<WeavableClass<T>, Class<T>,
      */
     public WeavableMethod<T> getWeavable(final Method methd) {
         if (methods.containsKey(methd)) {
-            final WeavableMethod<T> result = methods.get(methd);
-            return result;
+            return methods.get(methd);
         }
-        final WeavableMethod<T> result = new WeavableMethod<T>(methd, this);
+        final WeavableMethod<T> result = new WeavableMethod<>(methd, this);
         final WeavableMethod<T> faster = methods.putIfAbsent(methd, result);
         return faster == null ? result : faster;
     }
@@ -103,10 +89,9 @@ public class WeavableClass<T> extends NestedWeavable<WeavableClass<T>, Class<T>,
      */
     public WeavableConstructor<T> getWeavable(final Constructor<T> ctor) {
         if (ctors.containsKey(ctor)) {
-            final WeavableConstructor<T> result = ctors.get(ctor);
-            return result;
+            return ctors.get(ctor);
         }
-        final WeavableConstructor<T> result = new WeavableConstructor<T>(ctor, this);
+        final WeavableConstructor<T> result = new WeavableConstructor<>(ctor, this);
         final WeavableConstructor<T> faster = ctors.putIfAbsent(ctor, result);
         return faster == null ? result : faster;
     }
diff --git a/processor/src/main/java/org/apache/commons/weaver/model/WeavableConstructor.java b/processor/src/main/java/org/apache/commons/weaver/model/WeavableConstructor.java
index 79c1cb0..1a75c7b 100644
--- a/processor/src/main/java/org/apache/commons/weaver/model/WeavableConstructor.java
+++ b/processor/src/main/java/org/apache/commons/weaver/model/WeavableConstructor.java
@@ -52,5 +52,4 @@ public class WeavableConstructor<T> extends
     protected WeavableConstructorParameter<T> createParameter(final int index) {
         return new WeavableConstructorParameter<T>(Integer.valueOf(index), this);
     }
-
 }
diff --git a/processor/src/main/java/org/apache/commons/weaver/model/WeavableConstructorParameter.java b/processor/src/main/java/org/apache/commons/weaver/model/WeavableConstructorParameter.java
index 5ca5cc9..0b5c3d8 100644
--- a/processor/src/main/java/org/apache/commons/weaver/model/WeavableConstructorParameter.java
+++ b/processor/src/main/java/org/apache/commons/weaver/model/WeavableConstructorParameter.java
@@ -36,5 +36,4 @@ public class WeavableConstructorParameter<T> extends
     public WeavableConstructorParameter(final Integer target, final WeavableConstructor<T> parent) {
         super(target, parent);
     }
-
 }
diff --git a/processor/src/main/java/org/apache/commons/weaver/model/WeavableExecutable.java b/processor/src/main/java/org/apache/commons/weaver/model/WeavableExecutable.java
index 4a8b90f..d7df972 100644
--- a/processor/src/main/java/org/apache/commons/weaver/model/WeavableExecutable.java
+++ b/processor/src/main/java/org/apache/commons/weaver/model/WeavableExecutable.java
@@ -49,7 +49,7 @@ public abstract class WeavableExecutable
      */
     protected WeavableExecutable(final TARGET target, final WeavableClass<T> parent) {
         super(target, parent);
-        final List<P> params = new ArrayList<P>();
+        final List<P> params = new ArrayList<>();
         final int paramCount = getParameterTypes().length;
         for (int i = 0; i < paramCount; i++) {
             params.add(createParameter(i));
@@ -94,5 +94,4 @@ public abstract class WeavableExecutable
     public Iterable<P> getParameters() {
         return parameters;
     }
-
 }
diff --git a/processor/src/main/java/org/apache/commons/weaver/model/WeavableMethod.java b/processor/src/main/java/org/apache/commons/weaver/model/WeavableMethod.java
index eb79dec..1c80853 100644
--- a/processor/src/main/java/org/apache/commons/weaver/model/WeavableMethod.java
+++ b/processor/src/main/java/org/apache/commons/weaver/model/WeavableMethod.java
@@ -58,6 +58,6 @@ public class WeavableMethod<T> extends WeavableExecutable<WeavableMethod<T>, Met
      */
     @Override
     protected WeavableMethodParameter<T> createParameter(final int index) {
-        return new WeavableMethodParameter<T>(Integer.valueOf(index), this);
+        return new WeavableMethodParameter<>(Integer.valueOf(index), this);
     }
 }
diff --git a/processor/src/main/java/org/apache/commons/weaver/model/WeavableMethodParameter.java b/processor/src/main/java/org/apache/commons/weaver/model/WeavableMethodParameter.java
index 642119a..19bf38e 100644
--- a/processor/src/main/java/org/apache/commons/weaver/model/WeavableMethodParameter.java
+++ b/processor/src/main/java/org/apache/commons/weaver/model/WeavableMethodParameter.java
@@ -36,5 +36,4 @@ public class WeavableMethodParameter<T> extends
     public WeavableMethodParameter(final Integer target, final WeavableMethod<T> parent) {
         super(target, parent);
     }
-
 }
diff --git a/processor/src/main/java/org/apache/commons/weaver/model/WeavablePackage.java b/processor/src/main/java/org/apache/commons/weaver/model/WeavablePackage.java
index 993ac26..e1a5c9a 100644
--- a/processor/src/main/java/org/apache/commons/weaver/model/WeavablePackage.java
+++ b/processor/src/main/java/org/apache/commons/weaver/model/WeavablePackage.java
@@ -27,8 +27,7 @@ import java.util.concurrent.ConcurrentSkipListMap;
  */
 public class WeavablePackage extends Weavable<WeavablePackage, Package> {
 
-    private final ConcurrentNavigableMap<String, WeavableClass<?>> clazzes =
-        new ConcurrentSkipListMap<String, WeavableClass<?>>();
+    private final ConcurrentNavigableMap<String, WeavableClass<?>> clazzes = new ConcurrentSkipListMap<>();
 
     /**
      * Create a new {@link WeavablePackage} instance.
@@ -51,7 +50,7 @@ public class WeavablePackage extends Weavable<WeavablePackage, Package> {
             final WeavableClass<T> result = (WeavableClass<T>) clazzes.get(key);
             return result;
         }
-        final WeavableClass<T> result = new WeavableClass<T>(cls, this);
+        final WeavableClass<T> result = new WeavableClass<>(cls, this);
         @SuppressWarnings("unchecked")
         final WeavableClass<T> faster = (WeavableClass<T>) clazzes.putIfAbsent(key, result);
         return faster == null ? result : faster;
@@ -74,5 +73,4 @@ public class WeavablePackage extends Weavable<WeavablePackage, Package> {
     public int compareTo(final WeavablePackage arg0) {
         return getTarget().getName().compareTo(arg0.getTarget().getName());
     }
-
 }
diff --git a/processor/src/main/java/org/apache/commons/weaver/model/WeavableParameter.java b/processor/src/main/java/org/apache/commons/weaver/model/WeavableParameter.java
index 9ea5659..09d2d42 100644
--- a/processor/src/main/java/org/apache/commons/weaver/model/WeavableParameter.java
+++ b/processor/src/main/java/org/apache/commons/weaver/model/WeavableParameter.java
@@ -51,5 +51,4 @@ public abstract class WeavableParameter
     protected int localCompareTo(final SELF obj) {
         return getTarget().compareTo(getTarget());
     }
-
 }
diff --git a/processor/src/main/java/org/apache/commons/weaver/model/WeaveEnvironment.java b/processor/src/main/java/org/apache/commons/weaver/model/WeaveEnvironment.java
index e851127..565eb4b 100644
--- a/processor/src/main/java/org/apache/commons/weaver/model/WeaveEnvironment.java
+++ b/processor/src/main/java/org/apache/commons/weaver/model/WeaveEnvironment.java
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.Properties;
+import java.util.function.Supplier;
 import java.util.logging.Logger;
 
 import javax.activation.DataSource;
@@ -34,8 +35,6 @@ import org.apache.commons.weaver.spi.Weaver;
  * Encapsulates the environment in which a {@link Weaver} or {@link Cleaner} must operate.
  */
 public abstract class WeaveEnvironment {
-    private static final String CONTENT_TYPE = "application/octet-stream";
-
     private class Resource implements DataSource {
         private final String name;
 
@@ -79,6 +78,21 @@ public abstract class WeaveEnvironment {
         }
     }
 
+    private static final String CONTENT_TYPE = "application/octet-stream";
+
+    /**
+     * Convert a classname into a resource name.
+     * @param classname to convert
+     * @return String
+     */
+    protected static String getResourceName(final String classname) {
+        return classname.replace('.', '/') + ".class";
+    }
+
+    private static Supplier<String> supplier(String format, Object... args) {
+        return () -> String.format(format, args);
+    }
+
     /**
      * ClassLoader containing scannable and weavable classes.
      */
@@ -112,7 +126,7 @@ public abstract class WeaveEnvironment {
      * @see String#format(String, Object...)
      */
     public void debug(final String message, final Object... args) {
-        log.fine(String.format(message, args));
+        log.fine(supplier(message, args));
     }
 
     /**
@@ -122,7 +136,7 @@ public abstract class WeaveEnvironment {
      * @see String#format(String, Object...)
      */
     public void verbose(final String message, final Object... args) {
-        log.fine(String.format(message, args));
+        log.fine(supplier(message, args));
     }
 
     /**
@@ -132,7 +146,7 @@ public abstract class WeaveEnvironment {
      * @see String#format(String, Object...)
      */
     public void warn(final String message, final Object... args) {
-        log.warning(String.format(message, args));
+        log.warning(supplier(message, args));
     }
 
     /**
@@ -142,7 +156,7 @@ public abstract class WeaveEnvironment {
      * @see String#format(String, Object...)
      */
     public void info(final String message, final Object... args) {
-        log.info(String.format(message, args));
+        log.info(supplier(message, args));
     }
 
     /**
@@ -152,7 +166,7 @@ public abstract class WeaveEnvironment {
      * @see String#format(String, Object...)
      */
     public void error(final String message, final Object... args) {
-        log.severe(String.format(message, args));
+        log.severe(supplier(message, args));
     }
 
     /**
@@ -214,13 +228,4 @@ public abstract class WeaveEnvironment {
      * @throws IOException on error
      */
     protected abstract OutputStream getOutputStream(String resourceName) throws IOException;
-
-    /**
-     * Convert a classname into a resource name.
-     * @param classname to convert
-     * @return String
-     */
-    protected static String getResourceName(final String classname) {
-        return classname.replace('.', '/') + ".class";
-    }
 }
diff --git a/processor/src/main/java/org/apache/commons/weaver/model/WeaveInterest.java b/processor/src/main/java/org/apache/commons/weaver/model/WeaveInterest.java
index 6b23fac..3fa7a1e 100644
--- a/processor/src/main/java/org/apache/commons/weaver/model/WeaveInterest.java
+++ b/processor/src/main/java/org/apache/commons/weaver/model/WeaveInterest.java
@@ -28,6 +28,16 @@ import java.lang.annotation.ElementType;
 public final class WeaveInterest {
 
     /**
+     * Get a {@link WeaveInterest}.
+     * @param annotationType observed annotation type
+     * @param target attached element type
+     * @return {@link WeaveInterest}
+     */
+    public static WeaveInterest of(final Class<? extends Annotation> annotationType, final ElementType target) {
+        return new WeaveInterest(annotationType, target);
+    }
+
+    /**
      * Observed annotation type.
      */
     public final Class<? extends Annotation> annotationType;
@@ -42,14 +52,4 @@ public final class WeaveInterest {
         this.annotationType = annotationType;
         this.target = target;
     }
-
-    /**
-     * Get a {@link WeaveInterest}.
-     * @param annotationType observed annotation type
-     * @param target attached element type
-     * @return {@link WeaveInterest}
-     */
-    public static WeaveInterest of(final Class<? extends Annotation> annotationType, final ElementType target) {
-        return new WeaveInterest(annotationType, target);
-    }
 }
diff --git a/processor/src/main/java/org/apache/commons/weaver/utils/Args.java b/processor/src/main/java/org/apache/commons/weaver/utils/Args.java
index 23f18a9..8d31a1e 100644
--- a/processor/src/main/java/org/apache/commons/weaver/utils/Args.java
+++ b/processor/src/main/java/org/apache/commons/weaver/utils/Args.java
@@ -52,5 +52,4 @@ public final class Args {
         }
         return -1;
     }
-
 }
diff --git a/processor/src/main/java/org/apache/commons/weaver/utils/Providers.java b/processor/src/main/java/org/apache/commons/weaver/utils/Providers.java
index 8ed4f5d..5c919c8 100755
--- a/processor/src/main/java/org/apache/commons/weaver/utils/Providers.java
+++ b/processor/src/main/java/org/apache/commons/weaver/utils/Providers.java
@@ -28,8 +28,6 @@ import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.commons.collections4.Factory;
-import org.apache.commons.collections4.map.LazyMap;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.Validate;
 import org.apache.commons.weaver.Consumes;
@@ -56,18 +54,18 @@ public final class Providers {
 
             final Map<Class<? extends P>, Set<Class<? extends P>>> dependencyMap = toDependencyMap(providers);
 
-            final Collection<Class<? extends P>> order = new LinkedHashSet<Class<? extends P>>();
+            final Collection<Class<? extends P>> order = new LinkedHashSet<>();
 
-            final Map<Class<? extends P>, State> stateMap = new HashMap<Class<? extends P>, Providers.State>();
-            final Deque<Class<? extends P>> visiting = new ArrayDeque<Class<? extends P>>();
+            final Map<Class<? extends P>, State> stateMap = new HashMap<>();
+            final Deque<Class<? extends P>> visiting = new ArrayDeque<>();
 
             for (final Class<? extends P> type : dependencyMap.keySet()) {
                 final State state = stateMap.get(type);
 
                 if (state == null) {
                     tsort(type, dependencyMap, stateMap, visiting, order);
-                } else if (state == State.VISITING) {
-                    throw new RuntimeException("Unexpected node in visiting state: " + type);
+                } else {
+                    Validate.validState(state != State.VISITING, "Unexpected node in visiting state: %s", type);
                 }
             }
             return imposeOrder(providers, order);
@@ -154,22 +152,15 @@ public final class Providers {
          */
         private Map<Class<? extends P>, Set<Class<? extends P>>> toDependencyMap(final Iterable<P> providers) {
 
-            final Map<Class<? extends P>, Set<Class<? extends P>>> result = LazyMap.lazyMap(
-                new HashMap<Class<? extends P>, Set<Class<? extends P>>>(), new Factory<Set<Class<? extends P>>>() {
-
-                    @Override
-                    public Set<Class<? extends P>> create() {
-                        return new HashSet<Class<? extends P>>();
-                    }
-                });
+            final Map<Class<? extends P>, Set<Class<? extends P>>> result = new HashMap<>();
 
             for (final WeaveLifecycleProvider<?> provider : providers) {
                 @SuppressWarnings("unchecked")
                 final Class<? extends P> type = (Class<? extends P>) provider.getClass();
-                Collections.addAll(result.get(type), consumedBy(type));
+                Collections.addAll(result.computeIfAbsent(type, k -> new HashSet<>()), consumedBy(type));
 
                 for (final Class<? extends P> dependent : producedBy(type)) {
-                    result.get(dependent).add(type);
+                    result.computeIfAbsent(dependent, k -> new HashSet<>()).add(type);
                 }
             }
             return result;
@@ -184,7 +175,7 @@ public final class Providers {
          */
         private Iterable<P> imposeOrder(final Iterable<P> providers, final Iterable<Class<? extends P>> order) {
 
-            final Set<P> result = new LinkedHashSet<P>();
+            final Set<P> result = new LinkedHashSet<>();
 
             for (final Class<? extends P> type : order) {
                 for (final P provider : providers) {
@@ -195,10 +186,6 @@ public final class Providers {
             }
             return Collections.unmodifiableSet(result);
         }
-
-    }
-
-    private Providers() {
     }
 
     /**
@@ -212,4 +199,6 @@ public final class Providers {
         return new SortWorker<P>().sort(providers);
     }
 
+    private Providers() {
+    }
 }
diff --git a/processor/src/main/java/org/apache/commons/weaver/utils/URLArray.java b/processor/src/main/java/org/apache/commons/weaver/utils/URLArray.java
index 5a36acb..855354e 100644
--- a/processor/src/main/java/org/apache/commons/weaver/utils/URLArray.java
+++ b/processor/src/main/java/org/apache/commons/weaver/utils/URLArray.java
@@ -21,47 +21,20 @@ package org.apache.commons.weaver.utils;
 import java.io.File;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.Collection;
+import java.util.stream.Stream;
 
 /**
  * {@link URL} Array utilities.
  */
 public final class URLArray {
-    private URLArray() {
-    }
-
     /**
      * Convert an {@link Iterable} of filesystem paths.
      * @param files to convert
      * @return URL[]
      */
     public static URL[] fromPaths(final Iterable<String> files) {
-        return fromFiles(new Iterable<File>() {
-
-            @Override
-            public Iterator<File> iterator() {
-                final Iterator<String> path = files.iterator();
-                return new Iterator<File>() {
-
-                    @Override
-                    public boolean hasNext() {
-                        return path.hasNext();
-                    }
-
-                    @Override
-                    public File next() {
-                        final String element = path.next();
-                        return element == null ? null : new File(element);
-                    }
-
-                    @Override
-                    public void remove() {
-                        throw new UnsupportedOperationException();
-                    }
-                };
-            }
-        });
+        return fromFiles(() -> stream(files).map(e -> e == null ? null : new File(e)).iterator());
     }
 
     /**
@@ -70,19 +43,32 @@ public final class URLArray {
      * @return URL[]
      */
     public static URL[] fromFiles(final Iterable<File> files) {
-        final ArrayList<URL> result = new ArrayList<URL>();
-        for (final File file : files) {
-            if (file == null) {
-                result.add(null);
-                continue;
+        return fromFiles(stream(files));
+    }
+
+    private static URL[] fromFiles(final Stream<File> files) {
+        return files.map(f -> {
+            if (f == null) {
+                return null;
             }
             try {
-                result.add(file.toURI().toURL());
+                return f.toURI().toURL();
             } catch (final MalformedURLException e) {
                 // this shouldn't happen
                 throw new RuntimeException(e);
             }
+        }).toArray(URL[]::new);
+    }
+
+    private static <T> Stream<T> stream(Iterable<T> iterable) {
+        if (iterable instanceof Collection<?>) {
+            return ((Collection<T>) iterable).stream();
         }
-        return result.toArray(new URL[result.size()]);
+        final Stream.Builder<T> b = Stream.builder();
+        iterable.forEach(b);
+        return b.build();
+    }
+
+    private URLArray() {
     }
 }

-- 
To stop receiving notification emails like this one, please contact
mbenson@apache.org.

[commons-weaver] 05/13: remove shading for obsolete deps

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mbenson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-weaver.git

commit 3dd506f431bdc9fa5a563e27b653bd2ec8af05d0
Author: Matt Benson <mb...@apache.org>
AuthorDate: Fri Apr 20 11:07:21 2018 -0500

    remove shading for obsolete deps
---
 ant/pom.xml                       | 20 --------------------
 modules/privilizer/weaver/pom.xml | 11 -----------
 2 files changed, 31 deletions(-)

diff --git a/ant/pom.xml b/ant/pom.xml
index 0db620b..fcfbb7f 100644
--- a/ant/pom.xml
+++ b/ant/pom.xml
@@ -129,14 +129,6 @@ under the License.
 
               <relocations>
                 <relocation>
-                  <pattern>org.apache.commons.collections4.</pattern>
-                  <shadedPattern>org.apache.commons.weaver.ant._collections4.</shadedPattern>
-                </relocation>
-                <relocation>
-                  <pattern>org.apache.commons.io.</pattern>
-                  <shadedPattern>org.apache.commons.weaver.ant._io.</shadedPattern>
-                </relocation>
-                <relocation>
                   <pattern>org.apache.commons.lang3.</pattern>
                   <shadedPattern>org.apache.commons.weaver.ant._lang3.</shadedPattern>
                 </relocation>
@@ -147,18 +139,6 @@ under the License.
               </relocations>
               <filters>
                 <filter>
-                  <artifact>org.apache.commons:commons-collections4</artifact>
-                  <excludes>
-                    <exclude>META-INF/**</exclude>
-                  </excludes>
-                </filter>
-                <filter>
-                  <artifact>commons-io:commons-io</artifact>
-                  <excludes>
-                    <exclude>META-INF/**</exclude>
-                  </excludes>
-                </filter>
-                <filter>
                   <artifact>org.apache.commons:commons-lang3</artifact>
                   <excludes>
                     <exclude>META-INF/**</exclude>
diff --git a/modules/privilizer/weaver/pom.xml b/modules/privilizer/weaver/pom.xml
index 306fce1..9f561f7 100644
--- a/modules/privilizer/weaver/pom.xml
+++ b/modules/privilizer/weaver/pom.xml
@@ -97,7 +97,6 @@ under the License.
                   <artifactSet>
                     <includes>
                       <include>org.apache.commons:commons-lang3</include>
-                      <include>commons-io:commons-io</include>
                       <include>org.ow2.asm:*</include>
                     </includes>
                   </artifactSet>
@@ -107,10 +106,6 @@ under the License.
                       <shadedPattern>org.apache.commons.weaver.privilizer._lang3.</shadedPattern>
                     </relocation>
                     <relocation>
-                      <pattern>org.apache.commons.io.</pattern>
-                      <shadedPattern>org.apache.commons.weaver.privilizer._io.</shadedPattern>
-                    </relocation>
-                    <relocation>
                       <pattern>org.objectweb.asm.</pattern>
                       <shadedPattern>org.apache.commons.weaver.privilizer._asm.</shadedPattern>
                     </relocation>
@@ -123,12 +118,6 @@ under the License.
                       </excludes>
                     </filter>
                     <filter>
-                      <artifact>commons-io:commons-io</artifact>
-                      <excludes>
-                        <exclude>META-INF/**</exclude>
-                      </excludes>
-                    </filter>
-                    <filter>
                       <artifact>org.ow2.asm:*</artifact>
                       <excludes>
                         <exclude>META-INF/**</exclude>

-- 
To stop receiving notification emails like this one, please contact
mbenson@apache.org.

[commons-weaver] 07/13: upgrade xbean-finder

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mbenson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-weaver.git

commit 9fea2ca74d233c0fdfaee26529bff692ed355a97
Author: Matt Benson <mb...@apache.org>
AuthorDate: Fri Apr 20 11:20:03 2018 -0500

    upgrade xbean-finder
---
 ant/pom.xml                                              |  4 ++++
 modules/privilizer/weaver/pom.xml                        |  1 -
 parent/pom.xml                                           |  2 +-
 processor/pom.xml                                        | 11 +++++++++--
 .../src/main/java/org/apache/commons/weaver/Finder.java  | 16 ++++++++--------
 5 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/ant/pom.xml b/ant/pom.xml
index fcfbb7f..4ad1b24 100644
--- a/ant/pom.xml
+++ b/ant/pom.xml
@@ -65,8 +65,12 @@ under the License.
           <configuration>
             <parameter>
               <excludes>
+                <!-- API changes with xbean-finder-shaded -->
+                <exclude>org.apache.commons.weaver.Finder$Visitor</exclude>
+
                 <!-- shaded in; not part of public API -->
                 <exclude>org.apache.commons.weaver.ant._collections4</exclude>
+                <exclude>org.apache.commons.weaver.ant._xbean</exclude>
               </excludes>
             </parameter>
           </configuration>
diff --git a/modules/privilizer/weaver/pom.xml b/modules/privilizer/weaver/pom.xml
index 9f561f7..33b6cd1 100644
--- a/modules/privilizer/weaver/pom.xml
+++ b/modules/privilizer/weaver/pom.xml
@@ -36,7 +36,6 @@ under the License.
     <developerConnection>scm:svn:https://svn.apache.org/repos/asf/commons/proper/weaver/trunk/modules/privilizer/weaver</developerConnection>
     <url>http://svn.apache.org/viewvc/commons/proper/weaver/trunk/modules/privilizer/weaver</url>
   </scm>
-
   <dependencies>
     <dependency>
       <groupId>org.apache.commons</groupId>
diff --git a/parent/pom.xml b/parent/pom.xml
index d14d446..235b718 100755
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -152,7 +152,7 @@ under the License.
       <dependency>
         <groupId>org.apache.xbean</groupId>
         <artifactId>xbean-finder-shaded</artifactId>
-        <version>4.5</version>
+        <version>4.8</version>
       </dependency>
       <dependency>
         <groupId>org.apache.commons</groupId>
diff --git a/processor/pom.xml b/processor/pom.xml
index 275b544..0772486 100644
--- a/processor/pom.xml
+++ b/processor/pom.xml
@@ -68,8 +68,15 @@ under the License.
           <artifactId>japicmp-maven-plugin</artifactId>
           <configuration>
             <parameter>
-              <!-- obsolete dependency -->
-              <ignoreMissingClassesByRegularExpressions>org\.apache\.commons\.collections4\..+</ignoreMissingClassesByRegularExpressions>
+              <excludes>
+                <!-- API changes with xbean-finder-shaded -->
+                <exclude>org.apache.commons.weaver.Finder$Visitor</exclude>
+              </excludes>
+              <ignoreMissingClassesByRegularExpressions>
+                <!-- obsolete dependencies -->
+                <ignoreMissingClassesByRegularExpression>org\.apache\.commons\.collections4\..+</ignoreMissingClassesByRegularExpression>
+                <ignoreMissingClassesByRegularExpression>org\.apache\.xbean\.asm5\..+</ignoreMissingClassesByRegularExpression>
+              </ignoreMissingClassesByRegularExpressions>
             </parameter>
           </configuration>
         </plugin>
diff --git a/processor/src/main/java/org/apache/commons/weaver/Finder.java b/processor/src/main/java/org/apache/commons/weaver/Finder.java
index 9eb5b60..b08bc1b 100644
--- a/processor/src/main/java/org/apache/commons/weaver/Finder.java
+++ b/processor/src/main/java/org/apache/commons/weaver/Finder.java
@@ -48,13 +48,13 @@ import org.apache.commons.weaver.model.ScanResult;
 import org.apache.commons.weaver.model.Scanner;
 import org.apache.commons.weaver.model.WeaveInterest;
 import org.apache.commons.weaver.utils.Annotations;
-import org.apache.xbean.asm5.AnnotationVisitor;
-import org.apache.xbean.asm5.ClassReader;
-import org.apache.xbean.asm5.ClassVisitor;
-import org.apache.xbean.asm5.FieldVisitor;
-import org.apache.xbean.asm5.MethodVisitor;
-import org.apache.xbean.asm5.Opcodes;
-import org.apache.xbean.asm5.Type;
+import org.apache.xbean.asm6.AnnotationVisitor;
+import org.apache.xbean.asm6.ClassReader;
+import org.apache.xbean.asm6.ClassVisitor;
+import org.apache.xbean.asm6.FieldVisitor;
+import org.apache.xbean.asm6.MethodVisitor;
+import org.apache.xbean.asm6.Opcodes;
+import org.apache.xbean.asm6.Type;
 import org.apache.xbean.finder.Annotated;
 import org.apache.xbean.finder.AnnotationFinder;
 import org.apache.xbean.finder.Parameter;
@@ -494,7 +494,7 @@ class Finder extends AnnotationFinder implements Scanner {
         }
     }
 
-    private static final int ASM_VERSION = Opcodes.ASM5;
+    private static final int ASM_VERSION = Opcodes.ASM6;
     private static final int ASM_FLAGS = ClassReader.SKIP_CODE + ClassReader.SKIP_DEBUG + ClassReader.SKIP_FRAMES;
 
     private static final String INIT = "<init>";

-- 
To stop receiving notification emails like this one, please contact
mbenson@apache.org.

[commons-weaver] 03/13: centralize ASM versions

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mbenson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-weaver.git

commit ad16043d781a24e4d8d79be9114dd26fc2fccde3
Author: Matt Benson <mb...@apache.org>
AuthorDate: Thu Apr 19 18:01:04 2018 -0500

    centralize ASM versions
---
 .../org/apache/commons/weaver/normalizer/Normalizer.java    | 13 +++++++------
 .../commons/weaver/privilizer/BlueprintingVisitor.java      | 10 +++++-----
 .../weaver/privilizer/InlineNestedPrivilegedCalls.java      |  6 +++---
 .../org/apache/commons/weaver/privilizer/Privilizer.java    |  5 +++--
 .../apache/commons/weaver/privilizer/PrivilizerCleaner.java |  2 +-
 .../commons/weaver/privilizer/PrivilizingVisitor.java       |  2 +-
 .../src/main/java/org/apache/commons/weaver/Finder.java     |  9 +++++----
 7 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Normalizer.java b/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Normalizer.java
index 1c8be3f..d0be3dd 100644
--- a/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Normalizer.java
+++ b/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Normalizer.java
@@ -72,7 +72,7 @@ public class Normalizer {
     private static final class Inspector extends ClassVisitor {
         private final class InspectConstructor extends MethodVisitor {
             private InspectConstructor() {
-                super(Opcodes.ASM5);
+                super(ASM_VERSION);
             }
 
             @Override
@@ -104,7 +104,7 @@ public class Normalizer {
         private String superName;
 
         private Inspector() {
-            super(Opcodes.ASM5);
+            super(ASM_VERSION);
         }
 
         @Override
@@ -159,7 +159,7 @@ public class Normalizer {
     private static final class Remap extends ClassRemapper {
         private final class RewriteConstructor extends MethodVisitor {
             private RewriteConstructor(final MethodVisitor wrapped) {
-                super(Opcodes.ASM5, wrapped);
+                super(ASM_VERSION, wrapped);
             }
 
             @Override
@@ -240,11 +240,11 @@ public class Normalizer {
         private String className;
 
         WriteClass() {
-            super(Opcodes.ASM5, new CustomClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS));
+            super(ASM_VERSION, new CustomClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS));
         }
 
         WriteClass(final ClassReader reader) {
-            super(Opcodes.ASM5, new CustomClassWriter(reader, 0));
+            super(ASM_VERSION, new CustomClassWriter(reader, 0));
         }
 
         @Override
@@ -290,6 +290,7 @@ public class Normalizer {
      */
     public static final String CONFIG_TARGET_PACKAGE = CONFIG_WEAVER + "targetPackage";
 
+    private static final int ASM_VERSION = Opcodes.ASM5;
     private static final Charset UTF8 = Charset.forName(CharEncoding.UTF_8);
 
     private final WeaveEnvironment env;
@@ -507,7 +508,7 @@ public class Normalizer {
             // we're doing most of this by hand; we only read the original class to hijack signature, ctor exceptions,
             // etc.:
 
-            reader.accept(new ClassVisitor(Opcodes.ASM5) {
+            reader.accept(new ClassVisitor(ASM_VERSION) {
                 Type supertype;
 
                 @Override
diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/BlueprintingVisitor.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/BlueprintingVisitor.java
index 00a7049..a12e79d 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/BlueprintingVisitor.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/BlueprintingVisitor.java
@@ -72,7 +72,7 @@ class BlueprintingVisitor extends Privilizer.PrivilizerClassVisitor {
     BlueprintingVisitor(@SuppressWarnings("PMD.UnusedFormalParameter") final Privilizer privilizer, //false positive
         final ClassVisitor nextVisitor,
         final Privilizing config) {
-        privilizer.super(new ClassNode(Opcodes.ASM5));
+        privilizer.super(new ClassNode(Privilizer.ASM_VERSION));
         this.nextVisitor = nextVisitor;
 
         // load up blueprint methods:
@@ -117,7 +117,7 @@ class BlueprintingVisitor extends Privilizer.PrivilizerClassVisitor {
     }
 
     private ClassNode read(final String className) {
-        final ClassNode result = new ClassNode(Opcodes.ASM5);
+        final ClassNode result = new ClassNode(Privilizer.ASM_VERSION);
         try (InputStream bytecode = privilizer().env.getClassfile(className).getInputStream();) {
             new ClassReader(bytecode).accept(result, ClassReader.SKIP_DEBUG | ClassReader.EXPAND_FRAMES);
         } catch (final Exception e) {
@@ -167,7 +167,7 @@ class BlueprintingVisitor extends Privilizer.PrivilizerClassVisitor {
         // non-public fields accessed
         final Set<FieldAccess> fieldAccesses = new LinkedHashSet<>();
 
-        source.accept(new MethodVisitor(Opcodes.ASM5) {
+        source.accept(new MethodVisitor(Privilizer.ASM_VERSION) {
             @Override
             public void visitFieldInsn(final int opcode, final String owner, final String name, final String desc) {
                 final FieldAccess fieldAccess = fieldAccess(Type.getObjectType(owner), name);
@@ -253,7 +253,7 @@ class BlueprintingVisitor extends Privilizer.PrivilizerClassVisitor {
 
     private abstract class MethodInvocationHandler extends MethodVisitor {
         MethodInvocationHandler(final MethodVisitor mvr) {
-            super(Opcodes.ASM5, mvr);
+            super(Privilizer.ASM_VERSION, mvr);
         }
 
         @Override
@@ -323,7 +323,7 @@ class BlueprintingVisitor extends Privilizer.PrivilizerClassVisitor {
 
         AccessibleAdvisor(final MethodVisitor mvr, final int access, final String name, final String desc,
             final List<FieldAccess> fieldAccesses) {
-            super(ASM5, mvr, access, name, desc);
+            super(Privilizer.ASM_VERSION, mvr, access, name, desc);
             this.fieldAccesses = fieldAccesses;
         }
 
diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/InlineNestedPrivilegedCalls.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/InlineNestedPrivilegedCalls.java
index ddb6da5..c045b13 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/InlineNestedPrivilegedCalls.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/InlineNestedPrivilegedCalls.java
@@ -38,7 +38,7 @@ class InlineNestedPrivilegedCalls extends ClassNode {
             private final Method outer;
 
             private VisitMethod(final MethodVisitor orig, final Method outer) {
-                super(Opcodes.ASM5, orig);
+                super(Privilizer.ASM_VERSION, orig);
                 this.outer = outer;
             }
 
@@ -59,7 +59,7 @@ class InlineNestedPrivilegedCalls extends ClassNode {
         }
 
         private VisitEnd() {
-            super(Opcodes.ASM5, next);
+            super(Privilizer.ASM_VERSION, next);
         }
 
         @Override
@@ -92,7 +92,7 @@ class InlineNestedPrivilegedCalls extends ClassNode {
      */
     InlineNestedPrivilegedCalls(final Privilizer privilizer, final Map<Method, String> privilegedMethods,
         final ClassVisitor next) {
-        super(Opcodes.ASM5);
+        super(Privilizer.ASM_VERSION);
         this.privilizer = privilizer;
         this.privilegedMethods = privilegedMethods;
         this.next = next;
diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
index ffd4e33..ae8036b 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
@@ -56,7 +56,7 @@ public class Privilizer {
         }
 
         protected PrivilizerClassVisitor(final ClassVisitor cv) { //NOPMD
-            super(Opcodes.ASM5, cv);
+            super(ASM_VERSION, cv);
         }
 
         protected Privilizer privilizer() {
@@ -144,6 +144,7 @@ public class Privilizer {
 
     private static final String GENERATE_NAME = "__privileged_%s";
 
+    static final int ASM_VERSION = Opcodes.ASM5;
     static final Type[] EMPTY_TYPE_ARRAY = new Type[0];
 
     final WeaveEnvironment env;
@@ -240,7 +241,7 @@ public class Privilizer {
         }
         Validate.validState(StringUtils.isBlank(error), error);
 
-        final ClassVisitor checkInnerClasses = new ClassVisitor(Opcodes.ASM5, null) {
+        final ClassVisitor checkInnerClasses = new ClassVisitor(ASM_VERSION, null) {
             final Set<String> innerNames = new HashSet<>();
 
             @Override
diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerCleaner.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerCleaner.java
index 4c45ffa..78673f5 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerCleaner.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerCleaner.java
@@ -57,7 +57,7 @@ public class PrivilizerCleaner implements Cleaner {
 
             try (InputStream bytecode = privilizer.env.getClassfile(className).getInputStream()) {
                 final ClassReader classReader = new ClassReader(bytecode);
-                classReader.accept(new ClassVisitor(Opcodes.ASM5) {
+                classReader.accept(new ClassVisitor(Privilizer.ASM_VERSION) {
                     @Override
                     @SuppressWarnings("PMD.UseVarargs") // overridden method
                     public void visit(final int version, final int access, final String name, final String signature,
diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizingVisitor.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizingVisitor.java
index 8d4c1a5..ccfe259 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizingVisitor.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizingVisitor.java
@@ -92,7 +92,7 @@ class PrivilizingVisitor extends Privilizer.PrivilizerClassVisitor {
         final MethodVisitor originalMethod = super.visitMethod(access, name, desc, signature, exceptions);
         final Method methd = new Method(name, desc);
 
-        return new GeneratorAdapter(Opcodes.ASM5, originalMethod, access, name, desc) {
+        return new GeneratorAdapter(Privilizer.ASM_VERSION, originalMethod, access, name, desc) {
 
             @Override
             public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
diff --git a/processor/src/main/java/org/apache/commons/weaver/Finder.java b/processor/src/main/java/org/apache/commons/weaver/Finder.java
index 548998e..9eb5b60 100644
--- a/processor/src/main/java/org/apache/commons/weaver/Finder.java
+++ b/processor/src/main/java/org/apache/commons/weaver/Finder.java
@@ -110,7 +110,7 @@ class Finder extends AnnotationFinder implements Scanner {
 
     private abstract class AnnotationCapturer extends AnnotationVisitor {
         public AnnotationCapturer(final AnnotationVisitor wrapped) {
-            super(Opcodes.ASM5, wrapped);
+            super(ASM_VERSION, wrapped);
         }
 
         /**
@@ -196,7 +196,7 @@ class Finder extends AnnotationFinder implements Scanner {
         private final InfoBuildingVisitor wrapped;
 
         public Visitor(final InfoBuildingVisitor wrapped) {
-            super(Opcodes.ASM5, wrapped);
+            super(ASM_VERSION, wrapped);
             this.wrapped = wrapped;
         }
 
@@ -223,7 +223,7 @@ class Finder extends AnnotationFinder implements Scanner {
                 return toWrap;
             }
             final FieldInfo fieldInfo = testFieldInfo;
-            return new FieldVisitor(Opcodes.ASM5, toWrap) {
+            return new FieldVisitor(ASM_VERSION, toWrap) {
                 @Override
                 public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
                     final AnnotationVisitor toWrap = super.visitAnnotation(desc, visible);
@@ -258,7 +258,7 @@ class Finder extends AnnotationFinder implements Scanner {
                 return toWrap;
             }
             final MethodInfo methodInfo = testMethodInfo;
-            return new MethodVisitor(Opcodes.ASM5, toWrap) {
+            return new MethodVisitor(ASM_VERSION, toWrap) {
                 @Override
                 public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
                     final AnnotationVisitor toWrap = super.visitAnnotation(desc, visible);
@@ -494,6 +494,7 @@ class Finder extends AnnotationFinder implements Scanner {
         }
     }
 
+    private static final int ASM_VERSION = Opcodes.ASM5;
     private static final int ASM_FLAGS = ClassReader.SKIP_CODE + ClassReader.SKIP_DEBUG + ClassReader.SKIP_FRAMES;
 
     private static final String INIT = "<init>";

-- 
To stop receiving notification emails like this one, please contact
mbenson@apache.org.

[commons-weaver] 11/13: clone from ClassWriter#getCommonSuperClass

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mbenson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-weaver.git

commit 232f479747b016d307e214ad5906f82db0c5a58b
Author: Matt Benson <mb...@apache.org>
AuthorDate: Mon Apr 23 14:30:33 2018 -0500

    clone from ClassWriter#getCommonSuperClass
---
 .../commons/weaver/privilizer/Privilizer.java      | 31 ++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
index ae8036b..5da66bd 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
@@ -73,7 +73,7 @@ public class Privilizer {
         }
     }
 
-    private static final class CustomClassWriter extends ClassWriter {
+    private final class CustomClassWriter extends ClassWriter {
         CustomClassWriter(final int flags) {
             super(flags);
         }
@@ -84,7 +84,34 @@ public class Privilizer {
 
         @Override
         protected String getCommonSuperClass(final String type1, final String type2) {
-            return "java/lang/Object";
+//            https://gitlab.ow2.org/asm/asm/merge_requests/166
+            ClassLoader classLoader = env.classLoader;
+            Class<?> class1;
+            try {
+                class1 = Class.forName(type1.replace('/', '.'), false, classLoader);
+            } catch (Exception e) {
+                throw new TypeNotPresentException(type1, e);
+            }
+            Class<?> class2;
+            try {
+                class2 = Class.forName(type2.replace('/', '.'), false, classLoader);
+            } catch (Exception e) {
+                throw new TypeNotPresentException(type2, e);
+            }
+            if (class1.isAssignableFrom(class2)) {
+                return type1;
+            }
+            if (class2.isAssignableFrom(class1)) {
+                return type2;
+            }
+            if (class1.isInterface() || class2.isInterface()) {
+                return "java/lang/Object";
+            } else {
+                do {
+                    class1 = class1.getSuperclass();
+                } while (!class1.isAssignableFrom(class2));
+                return class1.getName().replace('.', '/');
+            }
         }
     }
 

-- 
To stop receiving notification emails like this one, please contact
mbenson@apache.org.

[commons-weaver] 13/13: upgrade to ASM API v6

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mbenson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-weaver.git

commit 52c0f9888fd7d8fb2f1db02be109067d4b91c1b3
Author: Matt Benson <mb...@thegeneral.com>
AuthorDate: Thu Apr 26 11:21:24 2018 -0500

    upgrade to ASM API v6
---
 .../src/main/java/org/apache/commons/weaver/normalizer/Normalizer.java  | 2 +-
 .../src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Normalizer.java b/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Normalizer.java
index 67b1c40..b40b225 100644
--- a/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Normalizer.java
+++ b/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Normalizer.java
@@ -289,7 +289,7 @@ public class Normalizer {
      */
     public static final String CONFIG_TARGET_PACKAGE = CONFIG_WEAVER + "targetPackage";
 
-    private static final int ASM_VERSION = Opcodes.ASM5;
+    private static final int ASM_VERSION = Opcodes.ASM6;
 
     private final WeaveEnvironment env;
 
diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
index 50f84f4..1fd50d8 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
@@ -171,7 +171,7 @@ public class Privilizer {
 
     private static final String GENERATE_NAME = "__privileged_%s";
 
-    static final int ASM_VERSION = Opcodes.ASM5;
+    static final int ASM_VERSION = Opcodes.ASM6;
     static final Type[] EMPTY_TYPE_ARRAY = new Type[0];
 
     static Type wrap(final Type type) {

-- 
To stop receiving notification emails like this one, please contact
mbenson@apache.org.

[commons-weaver] 02/13: remove obsolete dependencies

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mbenson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-weaver.git

commit 5f50c12f73c8e7e360c9f1b1f9c56134aaf76365
Author: Matt Benson <mb...@apache.org>
AuthorDate: Thu Apr 19 17:20:56 2018 -0500

    remove obsolete dependencies
---
 modules/normalizer/pom.xml                         |  4 ----
 .../commons/weaver/normalizer/Normalizer.java      |  3 +--
 modules/privilizer/weaver/pom.xml                  |  4 ----
 .../commons/weaver/privilizer/Privilizer.java      |  3 +--
 parent/pom.xml                                     | 12 +----------
 processor/pom.xml                                  | 24 ++++++++++++++--------
 6 files changed, 19 insertions(+), 31 deletions(-)

diff --git a/modules/normalizer/pom.xml b/modules/normalizer/pom.xml
index d27fcd8..961b330 100644
--- a/modules/normalizer/pom.xml
+++ b/modules/normalizer/pom.xml
@@ -53,10 +53,6 @@ under the License.
       <artifactId>commons-lang3</artifactId>
     </dependency>
     <dependency>
-      <groupId>commons-io</groupId>
-      <artifactId>commons-io</artifactId>
-    </dependency>
-    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <scope>test</scope>
diff --git a/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Normalizer.java b/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Normalizer.java
index b469c88..1c8be3f 100644
--- a/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Normalizer.java
+++ b/modules/normalizer/src/main/java/org/apache/commons/weaver/normalizer/Normalizer.java
@@ -34,7 +34,6 @@ import java.util.stream.Stream;
 
 import javax.activation.DataSource;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.CharEncoding;
 import org.apache.commons.lang3.Conversion;
@@ -264,7 +263,7 @@ public class Normalizer {
             final DataSource classfile = env.getClassfile(className);
             env.debug("Writing class %s to %s", className, classfile.getName());
             try (OutputStream outputStream = classfile.getOutputStream()) {
-                IOUtils.write(bytecode, outputStream);
+                outputStream.write(bytecode);
             } catch (final IOException e) {
                 throw new RuntimeException(e);
             }
diff --git a/modules/privilizer/weaver/pom.xml b/modules/privilizer/weaver/pom.xml
index bef4e15..306fce1 100644
--- a/modules/privilizer/weaver/pom.xml
+++ b/modules/privilizer/weaver/pom.xml
@@ -51,10 +51,6 @@ under the License.
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-lang3</artifactId>
     </dependency>
-    <dependency>
-      <groupId>commons-io</groupId>
-      <artifactId>commons-io</artifactId>
-    </dependency>
   </dependencies>
   <profiles>
     <profile>
diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
index d1e7ab4..ffd4e33 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
@@ -28,7 +28,6 @@ import java.util.Set;
 
 import javax.activation.DataSource;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.BooleanUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.Validate;
@@ -113,7 +112,7 @@ public class Privilizer {
             final DataSource classfile = env.getClassfile(className);
             env.debug("Writing class %s to resource %s", className, classfile.getName());
             try (OutputStream outputStream = classfile.getOutputStream()) {
-                IOUtils.write(bytecode, outputStream);
+                outputStream.write(bytecode);
             } catch (final IOException e) {
                 throw new RuntimeException(e);
             }
diff --git a/parent/pom.xml b/parent/pom.xml
index a99f7e7..754d607 100755
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -160,16 +160,6 @@ under the License.
         <version>3.4</version>
       </dependency>
       <dependency>
-        <groupId>org.apache.commons</groupId>
-        <artifactId>commons-collections4</artifactId>
-        <version>4.1</version>
-      </dependency>
-      <dependency>
-        <groupId>commons-io</groupId>
-        <artifactId>commons-io</artifactId>
-        <version>2.6</version>
-      </dependency>
-      <dependency>
         <groupId>org.ow2.asm</groupId>
         <artifactId>asm</artifactId>
         <version>${asm.version}</version>
@@ -244,7 +234,7 @@ under the License.
           <configuration>
             <parameter>
               <ignoreMissingNewVersion />
-	      <reportOnlyFilename>true</reportOnlyFilename>
+              <reportOnlyFilename>true</reportOnlyFilename>
             </parameter>
           </configuration>
         </plugin>
diff --git a/processor/pom.xml b/processor/pom.xml
index fbfe4bb..275b544 100644
--- a/processor/pom.xml
+++ b/processor/pom.xml
@@ -50,14 +50,6 @@ under the License.
       <artifactId>commons-lang3</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.commons</groupId>
-      <artifactId>commons-collections4</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>commons-io</groupId>
-      <artifactId>commons-io</artifactId>
-    </dependency>
-    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <scope>test</scope>
@@ -68,6 +60,22 @@ under the License.
       <scope>test</scope>
     </dependency>
   </dependencies>
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>com.github.siom79.japicmp</groupId>
+          <artifactId>japicmp-maven-plugin</artifactId>
+          <configuration>
+            <parameter>
+              <!-- obsolete dependency -->
+              <ignoreMissingClassesByRegularExpressions>org\.apache\.commons\.collections4\..+</ignoreMissingClassesByRegularExpressions>
+            </parameter>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
   <reporting>
     <plugins>
       <plugin>

-- 
To stop receiving notification emails like this one, please contact
mbenson@apache.org.

[commons-weaver] 10/13: upgrade modules to ASM 6.1

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mbenson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-weaver.git

commit b3b4583a1b8981739a569e0ef89b7ac141ed2ea8
Author: Matt Benson <mb...@apache.org>
AuthorDate: Fri Apr 20 15:28:05 2018 -0500

    upgrade modules to ASM 6.1
---
 LICENSE-asm5.1.txt => LICENSE-asm6.1.txt           |   0
 modules/normalizer/pom.xml                         |  44 ++----
 modules/privilizer/weaver/pom.xml                  | 155 +++++++++------------
 .../weaver/privilizer/BlueprintingVisitor.java     |   3 +-
 pom.xml                                            |   2 +-
 5 files changed, 80 insertions(+), 124 deletions(-)

diff --git a/LICENSE-asm5.1.txt b/LICENSE-asm6.1.txt
similarity index 100%
rename from LICENSE-asm5.1.txt
rename to LICENSE-asm6.1.txt
diff --git a/modules/normalizer/pom.xml b/modules/normalizer/pom.xml
index 961b330..d6d408a 100644
--- a/modules/normalizer/pom.xml
+++ b/modules/normalizer/pom.xml
@@ -49,6 +49,18 @@ under the License.
       <scope>provided</scope>
     </dependency>
     <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm-commons</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm-tree</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-lang3</artifactId>
     </dependency>
@@ -65,37 +77,6 @@ under the License.
       <scope>test</scope>
     </dependency>
   </dependencies>
-  <profiles>
-    <profile>
-      <id>basic</id>
-      <activation>
-        <activeByDefault>true</activeByDefault>
-      </activation>
-      <dependencies>
-        <dependency>
-          <groupId>org.ow2.asm</groupId>
-          <artifactId>asm</artifactId>
-        </dependency>
-        <dependency>
-          <groupId>org.ow2.asm</groupId>
-          <artifactId>asm-commons</artifactId>
-        </dependency>
-        <dependency>
-          <groupId>org.ow2.asm</groupId>
-          <artifactId>asm-tree</artifactId>
-        </dependency>
-      </dependencies>
-    </profile>
-    <profile>
-      <id>dev</id>
-      <dependencies>
-        <dependency>
-          <groupId>org.ow2.asm</groupId>
-          <artifactId>asm-debug-all</artifactId>
-        </dependency>
-      </dependencies>
-    </profile>
-  </profiles>
   <build>
     <plugins>
       <!-- shade plugin creates but does not clean ${project.basedir}/dependency-reduced-pom.xml -->
@@ -237,7 +218,6 @@ under the License.
             </goals>
             <configuration>
               <includeArtifactIds>commons-lang3</includeArtifactIds>
-
               <outputDirectory>${project.build.directory}/it/sample/lib</outputDirectory>
             </configuration>
           </execution>
diff --git a/modules/privilizer/weaver/pom.xml b/modules/privilizer/weaver/pom.xml
index 33b6cd1..b8e9301 100644
--- a/modules/privilizer/weaver/pom.xml
+++ b/modules/privilizer/weaver/pom.xml
@@ -47,99 +47,30 @@ under the License.
       <scope>provided</scope>
     </dependency>
     <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm-commons</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm-tree</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm-util</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm-analysis</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-lang3</artifactId>
     </dependency>
   </dependencies>
-  <profiles>
-    <profile>
-      <id>basic</id>
-      <activation>
-        <activeByDefault>true</activeByDefault>
-      </activation>
-      <dependencies>
-        <dependency>
-          <groupId>org.ow2.asm</groupId>
-          <artifactId>asm</artifactId>
-        </dependency>
-        <dependency>
-          <groupId>org.ow2.asm</groupId>
-          <artifactId>asm-commons</artifactId>
-        </dependency>
-        <dependency>
-          <groupId>org.ow2.asm</groupId>
-          <artifactId>asm-tree</artifactId>
-        </dependency>
-        <dependency>
-          <groupId>org.ow2.asm</groupId>
-          <artifactId>asm-util</artifactId>
-        </dependency>
-        <dependency>
-          <groupId>org.ow2.asm</groupId>
-          <artifactId>asm-analysis</artifactId>
-        </dependency>
-      </dependencies>
-      <build>
-        <plugins>
-          <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-shade-plugin</artifactId>
-            <executions>
-              <execution>
-                <id>shade</id>
-                <goals>
-                  <goal>shade</goal>
-                </goals>
-                <configuration>
-                  <minimizeJar>true</minimizeJar>
-                  <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
-                  <artifactSet>
-                    <includes>
-                      <include>org.apache.commons:commons-lang3</include>
-                      <include>org.ow2.asm:*</include>
-                    </includes>
-                  </artifactSet>
-                  <relocations>
-                    <relocation>
-                      <pattern>org.apache.commons.lang3.</pattern>
-                      <shadedPattern>org.apache.commons.weaver.privilizer._lang3.</shadedPattern>
-                    </relocation>
-                    <relocation>
-                      <pattern>org.objectweb.asm.</pattern>
-                      <shadedPattern>org.apache.commons.weaver.privilizer._asm.</shadedPattern>
-                    </relocation>
-                  </relocations>
-                  <filters>
-                    <filter>
-                      <artifact>org.apache.commons:commons-lang3</artifact>
-                      <excludes>
-                        <exclude>META-INF/**</exclude>
-                      </excludes>
-                    </filter>
-                    <filter>
-                      <artifact>org.ow2.asm:*</artifact>
-                      <excludes>
-                        <exclude>META-INF/**</exclude>
-                      </excludes>
-                    </filter>
-                  </filters>
-                </configuration>
-              </execution>
-            </executions>
-          </plugin>
-        </plugins>
-      </build>
-    </profile>
-    <profile>
-      <id>dev</id>
-      <dependencies>
-        <dependency>
-          <groupId>org.ow2.asm</groupId>
-          <artifactId>asm-debug-all</artifactId>
-        </dependency>
-      </dependencies>
-    </profile>
-  </profiles>
 
   <build>
     <plugins>
@@ -197,6 +128,52 @@ under the License.
           </filesets>
         </configuration>
       </plugin>
+       <plugin>
+         <groupId>org.apache.maven.plugins</groupId>
+         <artifactId>maven-shade-plugin</artifactId>
+         <executions>
+           <execution>
+             <id>shade</id>
+             <goals>
+               <goal>shade</goal>
+             </goals>
+             <configuration>
+               <minimizeJar>true</minimizeJar>
+               <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
+               <artifactSet>
+                 <includes>
+                   <include>org.apache.commons:commons-lang3</include>
+                   <include>org.ow2.asm:*</include>
+                 </includes>
+               </artifactSet>
+               <relocations>
+                 <relocation>
+                   <pattern>org.apache.commons.lang3.</pattern>
+                   <shadedPattern>org.apache.commons.weaver.privilizer._lang3.</shadedPattern>
+                 </relocation>
+                 <relocation>
+                   <pattern>org.objectweb.asm.</pattern>
+                   <shadedPattern>org.apache.commons.weaver.privilizer._asm.</shadedPattern>
+                 </relocation>
+               </relocations>
+               <filters>
+                 <filter>
+                   <artifact>org.apache.commons:commons-lang3</artifact>
+                   <excludes>
+                     <exclude>META-INF/**</exclude>
+                   </excludes>
+                 </filter>
+                 <filter>
+                   <artifact>org.ow2.asm:*</artifact>
+                   <excludes>
+                     <exclude>META-INF/**</exclude>
+                   </excludes>
+                 </filter>
+               </filters>
+             </configuration>
+           </execution>
+         </executions>
+       </plugin>
     </plugins>
   </build>
   <reporting>
diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/BlueprintingVisitor.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/BlueprintingVisitor.java
index a12e79d..b306a39 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/BlueprintingVisitor.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/BlueprintingVisitor.java
@@ -161,8 +161,7 @@ class BlueprintingVisitor extends Privilizer.PrivilizerClassVisitor {
 
         final MethodNode source = getMethods(key.getLeft()).get(key.getRight());
 
-        @SuppressWarnings("unchecked")
-        final String[] exceptions = ((List<String>) source.exceptions).toArray(ArrayUtils.EMPTY_STRING_ARRAY);
+        final String[] exceptions = source.exceptions.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
 
         // non-public fields accessed
         final Set<FieldAccess> fieldAccesses = new LinkedHashSet<>();
diff --git a/pom.xml b/pom.xml
index 73330bd..a7bc55d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,7 +65,7 @@ under the License.
     <maven.compiler.target>1.8</maven.compiler.target>
 
     <ant.version>1.9.4</ant.version>
-    <asm.version>5.1</asm.version>
+    <asm.version>6.1</asm.version>
   </properties>
 
   <developers>

-- 
To stop receiving notification emails like this one, please contact
mbenson@apache.org.

[commons-weaver] 04/13: upgrade commons-lang3

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mbenson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-weaver.git

commit 11f857a71e4ea75bcba4bfcd8ae66c912388f3e6
Author: Matt Benson <mb...@apache.org>
AuthorDate: Fri Apr 20 11:07:02 2018 -0500

    upgrade commons-lang3
---
 parent/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/parent/pom.xml b/parent/pom.xml
index 754d607..d14d446 100755
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -157,7 +157,7 @@ under the License.
       <dependency>
         <groupId>org.apache.commons</groupId>
         <artifactId>commons-lang3</artifactId>
-        <version>3.4</version>
+        <version>3.7</version>
       </dependency>
       <dependency>
         <groupId>org.ow2.asm</groupId>

-- 
To stop receiving notification emails like this one, please contact
mbenson@apache.org.

[commons-weaver] 08/13: small cleanups

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mbenson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-weaver.git

commit c419b33493ab5578e3a2d73675bcfd3b2111b215
Author: Matt Benson <mb...@apache.org>
AuthorDate: Fri Apr 20 11:26:46 2018 -0500

    small cleanups
---
 .../org/apache/commons/weaver/privilizer/ActionGenerator.java     | 2 +-
 .../commons/weaver/privilizer/InlineNestedPrivilegedCalls.java    | 1 -
 .../org/apache/commons/weaver/privilizer/PrivilizerCleaner.java   | 1 -
 .../org/apache/commons/weaver/privilizer/PrivilizingVisitor.java  | 8 ++------
 4 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/ActionGenerator.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/ActionGenerator.java
index 20f2121..9f880a8 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/ActionGenerator.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/ActionGenerator.java
@@ -86,7 +86,7 @@ class ActionGenerator extends Privilizer.WriteClass implements Builder<Type> {
         this.impl = new Method(implName, methd.getDescriptor());
         this.implIsStatic = Modifier.isStatic(access);
         final Type[] args =
-            implIsStatic ? methd.getArgumentTypes() : ArrayUtils.add(methd.getArgumentTypes(), 0, owner.target);
+            implIsStatic ? methd.getArgumentTypes() : ArrayUtils.insert(0, methd.getArgumentTypes(), owner.target);
         this.helper = new Method(privilizer().generateName("access$" + index), methd.getReturnType(), args);
         this.result = privilizer().wrap(methd.getReturnType());
         this.fields = fields(args);
diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/InlineNestedPrivilegedCalls.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/InlineNestedPrivilegedCalls.java
index c045b13..2795a22 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/InlineNestedPrivilegedCalls.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/InlineNestedPrivilegedCalls.java
@@ -22,7 +22,6 @@ import java.util.Map;
 
 import org.objectweb.asm.ClassVisitor;
 import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
 import org.objectweb.asm.commons.Method;
 import org.objectweb.asm.tree.ClassNode;
 
diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerCleaner.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerCleaner.java
index 78673f5..bb09954 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerCleaner.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerCleaner.java
@@ -31,7 +31,6 @@ import org.apache.commons.weaver.model.WeaveInterest;
 import org.apache.commons.weaver.spi.Cleaner;
 import org.objectweb.asm.ClassReader;
 import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.Opcodes;
 
 /**
  * Removes classes privilized with a different policy.
diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizingVisitor.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizingVisitor.java
index ccfe259..09c8cce 100644
--- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizingVisitor.java
+++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizingVisitor.java
@@ -149,12 +149,8 @@ class PrivilizingVisitor extends Privilizer.PrivilizerClassVisitor {
                     privilizer().env.debug("setting up unconditional privileged execution due to policy %s", policy);
                 }
                 // generate action:
-                final Type[] ctorArgs;
-                if (instanceMethod) {
-                    ctorArgs = ArrayUtils.add(methd.getArgumentTypes(), 0, target);
-                } else {
-                    ctorArgs = methd.getArgumentTypes();
-                }
+                final Type[] ctorArgs =
+                    instanceMethod ? ArrayUtils.insert(0, methd.getArgumentTypes(), target) : methd.getArgumentTypes();
                 final Type actionType = new ActionGenerator(access, methd, exceptions, PrivilizingVisitor.this).build();
                 newInstance(actionType);
                 dup();

-- 
To stop receiving notification emails like this one, please contact
mbenson@apache.org.