]> source.dussan.org Git - aspectj.git/commitdiff
Update 'weaver' code to use generics 113/head
authorAndrey Turbanov <turbanoff@gmail.com>
Fri, 14 Jan 2022 19:34:54 +0000 (22:34 +0300)
committerAndrey Turbanov <turbanoff@gmail.com>
Fri, 14 Jan 2022 19:34:54 +0000 (22:34 +0300)
weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java
weaver/src/main/java/org/aspectj/weaver/bcel/ExtensibleURLClassLoader.java
weaver/src/main/java/org/aspectj/weaver/loadtime/definition/LightXMLParser.java
weaver/src/main/java/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java
weaver/src/main/java/org/aspectj/weaver/ltw/LTWWorld.java
weaver/src/main/java/org/aspectj/weaver/reflect/Java15AnnotationFinder.java
weaver/src/main/java/org/aspectj/weaver/reflect/Java15GenericSignatureInformationProvider.java
weaver/src/main/java/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java
weaver/src/main/java/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java
weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java

index 51f0a8c6c2c448ca8cc8f2186adc55d72f53ab22..53f71df5689d978d7e036eeaf1b67f9fa3e3bbaa 100644 (file)
@@ -386,7 +386,7 @@ public class BcelWeaver {
                                inJar = new JarFile(inFile);
                                try {
                                        addManifest(inJar.getManifest());
-                                       Enumeration entries = inJar.entries();
+                                       Enumeration<JarEntry> entries = inJar.entries();
 
                                        while (entries.hasMoreElements()) {
                                                JarEntry entry = (JarEntry) entries.nextElement();
@@ -878,7 +878,7 @@ public class BcelWeaver {
                return true;
        }
 
-       private Pointcut findFirstPointcutIn(Pointcut toSearch, Class toLookFor) {
+       private Pointcut findFirstPointcutIn(Pointcut toSearch, Class<?> toLookFor) {
                if (toSearch instanceof NotPointcut) {
                        return null;
                }
@@ -946,7 +946,7 @@ public class BcelWeaver {
 
                        manifest = new Manifest();
 
-                       Map attributes = manifest.getMainAttributes();
+                       Attributes attributes = manifest.getMainAttributes();
                        attributes.put(Name.MANIFEST_VERSION, WEAVER_MANIFEST_VERSION);
                        attributes.put(CREATED_BY, WEAVER_CREATED_BY);
                }
@@ -1254,7 +1254,7 @@ public class BcelWeaver {
                // if a piece of advice hasn't matched anywhere and we are in -1.5 mode,
                // put out a warning
                if (world.isInJava5Mode() && world.getLint().adviceDidNotMatch.isEnabled()) {
-                       List l = world.getCrosscuttingMembersSet().getShadowMungers();
+                       List<ShadowMunger> l = world.getCrosscuttingMembersSet().getShadowMungers();
                        Set<AdviceLocation> alreadyWarnedLocations = new HashSet<>();
 
                        for (Object o : l) {
index 54aefa4b8a20ada04ab47b864ffd4c484ff124b7..dd372e5e2fe752e85726eac4cf5c7f3438f5db26 100644 (file)
@@ -87,7 +87,7 @@ public abstract class ExtensibleURLClassLoader extends URLClassLoader {
                return b;
        }
 
-       private Class defineClass(String name, byte[] bytes /* ClassPathManager.ClassFile classFile */) throws IOException {
+       private Class<?> defineClass(String name, byte[] bytes /* ClassPathManager.ClassFile classFile */) throws IOException {
                String packageName = getPackageName(name);
                if (packageName != null) {
                        Package pakkage = getPackage(packageName);
index 3d3fba4306dd0b059911003d649df58d33e77d70..c076c3a2f92d967eb9d89dac1a7d90e92641017b 100644 (file)
@@ -20,7 +20,7 @@ public class LightXMLParser {
 
        private final static char NULL_CHAR = '\0';
        private Map<String, Object> attributes;
-       private ArrayList children;
+       private ArrayList<LightXMLParser> children;
        private String name;
        private char pushedBackChar;
        private Reader reader;
@@ -38,7 +38,7 @@ public class LightXMLParser {
        public LightXMLParser() {
                this.name = null;
                this.attributes = new HashMap<>();
-               this.children = new ArrayList();
+               this.children = new ArrayList<>();
        }
 
        public ArrayList getChildrens() {
@@ -53,7 +53,7 @@ public class LightXMLParser {
                this.pushedBackChar = NULL_CHAR;
                this.attributes = new HashMap<>();
                this.name = null;
-               this.children = new ArrayList();
+               this.children = new ArrayList<>();
                this.reader = reader;
 
                while (true) {
index c73b51af1fce2d00ea59119f67af8f5203e4e1fb..223d2c4321c9720f3c1381990dc45b6df788251b 100644 (file)
@@ -80,7 +80,7 @@ public class SimpleAOPParser {
                return sap.m_definition;
        }
 
-       private void startElement(String qName, Map attrMap) throws Exception {
+       private void startElement(String qName, Map<String, Object> attrMap) throws Exception {
                if (ASPECT_ELEMENT.equals(qName)) {
                        String name = (String) attrMap.get(NAME_ATTRIBUTE);
                        String scopePattern = replaceXmlAnd((String) attrMap
@@ -233,7 +233,7 @@ public class SimpleAOPParser {
                }
        }
 
-       private String getWithinAttribute(Map attributes) {
+       private String getWithinAttribute(Map<String, Object> attributes) {
                return replaceXmlAnd((String) attributes.get(WITHIN_ATTRIBUTE));
        }
 
@@ -253,7 +253,7 @@ public class SimpleAOPParser {
        private static void traverse(SimpleAOPParser sap, LightXMLParser xml)
                        throws Exception {
                sap.startElement(xml.getName(), xml.getAttributes());
-               Iterable childrens = xml.getChildrens();
+               Iterable<LightXMLParser> childrens = xml.getChildrens();
                for (Object children : childrens) {
                        LightXMLParser child = (LightXMLParser) children;
                        traverse(sap, child);
index 7dc8b7dd49f610a3b2f69c6b760bd5afe308f40b..4677a39397e9bdd02547fc23a805714342662a10 100644 (file)
@@ -177,17 +177,17 @@ public class LTWWorld extends BcelWorld implements IReflectionWorld {
                return ReflectionWorld.resolve(this, aClass);
        }
 
-       private static Map makeConcurrentMap() {
+       private static Map<?, ?> makeConcurrentMap() {
                if (concurrentMapClass != null) {
                        try {
                                return (Map) concurrentMapClass.getDeclaredConstructor().newInstance();
                        } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException ignored) {}
                        // fall through if exceptions
                }
-               return Collections.synchronizedMap(new HashMap());
+               return Collections.synchronizedMap(new HashMap<>());
        }
 
-       private static Class makeConcurrentMapClass() {
+       private static Class<?> makeConcurrentMapClass() {
                String betterChoices[] = { "java.util.concurrent.ConcurrentHashMap",
                                "edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap",
                                "EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap" };
@@ -215,7 +215,7 @@ public class LTWWorld extends BcelWorld implements IReflectionWorld {
        // One type is completed at a time, if multiple need doing then they
        // are queued up
        private boolean typeCompletionInProgress = false;
-       private List/* ResolvedType */typesForCompletion = new ArrayList();
+       private List<ResolvedType> typesForCompletion = new ArrayList<>();
 
        @Override
        protected void completeBinaryType(ResolvedType ret) {
index dfddd18da673a5ba62a3318bc8ad792c8a3b7601..d60857950c9321a160d72d421bbbbbccff0d879a 100644 (file)
@@ -138,7 +138,7 @@ public class Java15AnnotationFinder implements AnnotationFinder, ArgNameFinder {
                                        anns = bcelMethod.getAnnotations();
                                }
                        } else if (onMember instanceof Constructor) {
-                               org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor) onMember);
+                               org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor<?>) onMember);
                                anns = bcelCons.getAnnotations();
                        } else if (onMember instanceof Field) {
                                org.aspectj.apache.bcel.classfile.Field bcelField = jc.getField((Field) onMember);
@@ -208,7 +208,7 @@ public class Java15AnnotationFinder implements AnnotationFinder, ArgNameFinder {
                                                anns = bcelMethod.getAnnotations();
                                        }
                                } else if (onMember instanceof Constructor) {
-                                       org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor) onMember);
+                                       org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor<?>) onMember);
                                        anns = bcelCons.getAnnotations();
                                } else if (onMember instanceof Field) {
                                        org.aspectj.apache.bcel.classfile.Field bcelField = jc.getField((Field) onMember);
@@ -284,7 +284,7 @@ public class Java15AnnotationFinder implements AnnotationFinder, ArgNameFinder {
                                lvt = bcelMethod.getLocalVariableTable();
                                numVars = bcelMethod.getArgumentTypes().length;
                        } else if (forMember instanceof Constructor) {
-                               org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor) forMember);
+                               org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor<?>) forMember);
                                lvt = bcelCons.getLocalVariableTable();
                                numVars = bcelCons.getArgumentTypes().length;
                        }
@@ -334,7 +334,7 @@ public class Java15AnnotationFinder implements AnnotationFinder, ArgNameFinder {
                                        anns = bcelMethod.getParameterAnnotations();
                                }
                        } else if (onMember instanceof Constructor) {
-                               org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor) onMember);
+                               org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor<?>) onMember);
                                anns = bcelCons.getParameterAnnotations();
                        } else if (onMember instanceof Field) {
                                // anns = null;
@@ -364,7 +364,7 @@ public class Java15AnnotationFinder implements AnnotationFinder, ArgNameFinder {
                if (onMember instanceof Method) {
                        anns = ((Method) ao).getParameterAnnotations();
                } else if (onMember instanceof Constructor) {
-                       anns = ((Constructor) ao).getParameterAnnotations();
+                       anns = ((Constructor<?>) ao).getParameterAnnotations();
                } else if (onMember instanceof Field) {
                        // anns = null;
                }
index 3d298023eab96590a15bbd1b7f1bfbe0435b1469..69030fbd4e1ade1e6afcdd5b8960c217c5c478db 100644 (file)
@@ -43,7 +43,7 @@ public class Java15GenericSignatureInformationProvider implements
                if (member instanceof Method) {
                        pTypes = ((Method)member).getGenericParameterTypes();
                } else if (member instanceof Constructor) {
-                       pTypes = ((Constructor)member).getGenericParameterTypes();
+                       pTypes = ((Constructor<?>)member).getGenericParameterTypes();
                }
                return typeConverter.fromTypes(pTypes);
        }
@@ -60,7 +60,7 @@ public class Java15GenericSignatureInformationProvider implements
                } else if (member instanceof Method) {
                        return typeConverter.fromType(((Method)member).getGenericReturnType());
                } else if (member instanceof Constructor) {
-                       return typeConverter.fromType(((Constructor)member).getDeclaringClass());
+                       return typeConverter.fromType(((Constructor<?>)member).getDeclaringClass());
                } else {
                        throw new IllegalStateException("unexpected member type: " + member);
                }
@@ -86,7 +86,7 @@ public class Java15GenericSignatureInformationProvider implements
                if (member instanceof Method) {
                        return ((Method)member).isVarArgs();
                } else if (member instanceof Constructor) {
-                       return ((Constructor)member).isVarArgs();
+                       return ((Constructor<?>)member).isVarArgs();
                } else {
                        return false;
                }
index a9527b6f7bbe473a3e51f4ad10bb687e6ee2ad6d..485aa0a7647afba546885c1ab407d0ea553b100d 100644 (file)
@@ -235,7 +235,7 @@ public class Java15ReflectionBasedReferenceTypeDelegate extends ReflectionBasedR
                return ret;
        }
 
-       private ResolvedMember createGenericConstructorMember(Constructor forConstructor) {
+       private ResolvedMember createGenericConstructorMember(Constructor<?> forConstructor) {
                ReflectionBasedResolvedMemberImpl ret = new ReflectionBasedResolvedMemberImpl(org.aspectj.weaver.Member.METHOD,
                                getGenericResolvedType(), forConstructor.getModifiers(),
                                // to return what BCEL returns the return type is void
@@ -268,7 +268,7 @@ public class Java15ReflectionBasedReferenceTypeDelegate extends ReflectionBasedR
                        } else {
                                parser = new InternalUseOnlyPointcutParser(classLoaderReference.getClassLoader());
                        }
-                       Set additionalPointcutHandlers = world.getRegisteredPointcutHandlers();
+                       Set<PointcutDesignatorHandler> additionalPointcutHandlers = world.getRegisteredPointcutHandlers();
                        for (Object additionalPointcutHandler : additionalPointcutHandlers) {
                                PointcutDesignatorHandler handler = (PointcutDesignatorHandler) additionalPointcutHandler;
                                parser.registerPointcutDesignatorHandler(handler);
index caf984821434ee315b6b1dca50dd747bda8e6d95..be8123ebb592b778b648c6bea6ca02ad8920b1c6 100644 (file)
@@ -45,7 +45,7 @@ public class JavaLangTypeToResolvedTypeConverter {
 
        public ResolvedType fromType(Type type) {
                if (type instanceof Class) {
-                       Class clazz = (Class) type;
+                       Class<?> clazz = (Class<?>) type;
                        String name = clazz.getName();
                        /**
                         * getName() can return:
@@ -87,7 +87,7 @@ public class JavaLangTypeToResolvedTypeConverter {
                        if (inprogressVar != null) {
                                return inprogressVar;
                        }
-                       java.lang.reflect.TypeVariable tv = (java.lang.reflect.TypeVariable) type;
+                       java.lang.reflect.TypeVariable<?> tv = (java.lang.reflect.TypeVariable<?>) type;
                        TypeVariable rt_tv = new TypeVariable(tv.getName());
                        TypeVariableReferenceType tvrt = new TypeVariableReferenceType(rt_tv, getWorld());
                        typeVariablesInProgress.put(type, tvrt); // record what we are working on, for recursion case
index 00346a0fbded5af54d8fcc705c5246f2facb9579..f64fc87d5d4af359b8654eab4dd7898a1348bac2 100644 (file)
@@ -566,7 +566,7 @@ public class WeavingAdaptor implements IMessageContext {
                return wcp.getBytes();
        }
 
-       private void registerAspectLibraries(List aspectPath) {
+       private void registerAspectLibraries(List<String> aspectPath) {
                // System.err.println("? WeavingAdaptor.registerAspectLibraries(" + aspectPath + ")");
                for (Object o : aspectPath) {
                        String libName = (String) o;