diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2021-03-21 17:34:09 +0700 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2021-03-21 17:34:09 +0700 |
commit | ecb5320c7b61d72edbf4a440e4996171a9c8f7dd (patch) | |
tree | 2b5496ad42ca47d0f3c7e636f2130dbb4d8b6e2c | |
parent | e4a2a5a5d274bc16bae3d1178789752dba043730 (diff) | |
download | aspectj-ecb5320c7b61d72edbf4a440e4996171a9c8f7dd.tar.gz aspectj-ecb5320c7b61d72edbf4a440e4996171a9c8f7dd.zip |
Fix some deprecated Java and JUnit warnings by using newer API calls
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
33 files changed, 73 insertions, 71 deletions
diff --git a/asm/src/main/java/org/aspectj/asm/AsmManager.java b/asm/src/main/java/org/aspectj/asm/AsmManager.java index eaf728296..cbebe2842 100644 --- a/asm/src/main/java/org/aspectj/asm/AsmManager.java +++ b/asm/src/main/java/org/aspectj/asm/AsmManager.java @@ -1173,8 +1173,8 @@ public class AsmManager implements IStructureModel { private ModelInfo(IHierarchy hierarchy, IRelationshipMap relationshipMap) { IProgramElement ipe = hierarchy.getRoot(); walkModel(ipe); - recordStat("FileMapSize", new Integer(hierarchy.getFileMapEntrySet().size()).toString()); - recordStat("RelationshipMapSize", new Integer(relationshipMap.getEntries().size()).toString()); + recordStat("FileMapSize", Integer.toString(hierarchy.getFileMapEntrySet().size())); + recordStat("RelationshipMapSize", Integer.toString(relationshipMap.getEntries().size())); } private void walkModel(IProgramElement ipe) { diff --git a/asm/src/main/java/org/aspectj/asm/internal/JDTLikeHandleProvider.java b/asm/src/main/java/org/aspectj/asm/internal/JDTLikeHandleProvider.java index 60a823e20..0ae669502 100644 --- a/asm/src/main/java/org/aspectj/asm/internal/JDTLikeHandleProvider.java +++ b/asm/src/main/java/org/aspectj/asm/internal/JDTLikeHandleProvider.java @@ -171,7 +171,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { String existingHandle = object.getHandleIdentifier(); int suffixPosition = existingHandle.indexOf('!'); if (suffixPosition != -1) { - count = new Integer(existingHandle.substring(suffixPosition + 1)) + 1; + count = Integer.parseInt(existingHandle.substring(suffixPosition + 1)) + 1; } else { if (count == 1) { count = 2; @@ -181,13 +181,13 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { } } if (count > 1) { - return CharOperation.concat(countDelim, new Integer(count).toString().toCharArray()); + return CharOperation.concat(countDelim, Integer.toString(count).toCharArray()); } } else if (ipe.getKind().isDeclare()) { // // look at peer declares int count = computeCountBasedOnPeers(ipe); if (count > 1) { - return CharOperation.concat(countDelim, new Integer(count).toString().toCharArray()); + return CharOperation.concat(countDelim, Integer.toString(count).toCharArray()); } } else if (ipe.getKind().equals(IProgramElement.Kind.ADVICE)) { // Look at any peer advice @@ -227,7 +227,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { String existingHandle = object.getHandleIdentifier(); int suffixPosition = existingHandle.indexOf('!'); if (suffixPosition != -1) { - count = new Integer(existingHandle.substring(suffixPosition + 1)) + 1; + count = Integer.valueOf(existingHandle.substring(suffixPosition + 1)) + 1; } else { if (count == 1) { count = 2; @@ -238,7 +238,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { } } if (count > 1) { - return CharOperation.concat(countDelim, new Integer(count).toString().toCharArray()); + return CharOperation.concat(countDelim, Integer.toString(count).toCharArray()); } } else if (ipe.getKind().equals(IProgramElement.Kind.INITIALIZER)) { // return String.valueOf(++initializerCounter).toCharArray(); @@ -279,7 +279,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { String existingHandle = object.getHandleIdentifier(); int suffixPosition = existingHandle.indexOf('!'); if (suffixPosition != -1) { - count = new Integer(existingHandle.substring(suffixPosition + 1)) + 1; + count = Integer.valueOf(existingHandle.substring(suffixPosition + 1)) + 1; } else { if (count == 1) { count = 2; @@ -290,7 +290,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { } } // if (count > 1) { - return new Integer(count).toString().toCharArray(); + return Integer.toString(count).toCharArray(); // return CharOperation.concat(countDelim, new Integer(count).toString().toCharArray()); // } } else if (ipe.getKind().equals(IProgramElement.Kind.CODE)) { @@ -314,7 +314,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { int suffixPosition = existingHandle.lastIndexOf('!'); int lastSquareBracket = existingHandle.lastIndexOf('['); // type delimiter if (suffixPosition != -1 && lastSquareBracket < suffixPosition) { // pr260384 - count = new Integer(existingHandle.substring(suffixPosition + 1)) + 1; + count = Integer.valueOf(existingHandle.substring(suffixPosition + 1)) + 1; } else { if (count == 1) { count = 2; @@ -334,7 +334,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { int suffixPosition = existingHandle.lastIndexOf('!'); int lastSquareBracket = existingHandle.lastIndexOf('['); // type delimiter if (suffixPosition != -1 && lastSquareBracket < suffixPosition) { // pr260384 - count = new Integer(existingHandle.substring(suffixPosition + 1)) + 1; + count = Integer.valueOf(existingHandle.substring(suffixPosition + 1)) + 1; } else { if (count == 1) { count = 2; @@ -345,7 +345,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { } } if (count > 1) { - return CharOperation.concat(countDelim, new Integer(count).toString().toCharArray()); + return CharOperation.concat(countDelim, Integer.toString(count).toCharArray()); } } return empty; @@ -383,7 +383,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { String existingHandle = object.getHandleIdentifier(); int suffixPosition = existingHandle.indexOf('!'); if (suffixPosition != -1) { - count = new Integer(existingHandle.substring(suffixPosition + 1)) + 1; + count = Integer.valueOf(existingHandle.substring(suffixPosition + 1)) + 1; } else { if (count == 1) { count = 2; diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValue.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValue.java index 2c795b136..fabfa8ca4 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValue.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValue.java @@ -239,7 +239,7 @@ public class SimpleElementValue extends ElementValue { return Integer.toString(b.getValue()); case PRIMITIVE_CHAR: ConstantInteger ch = (ConstantInteger) cpool.getConstant(idx); - return new Character((char) ch.getIntValue()).toString(); + return Character.toString((char) ch.getIntValue()); case PRIMITIVE_BOOLEAN: ConstantInteger bo = (ConstantInteger) cpool.getConstant(idx); if (bo.getValue() == 0) { @@ -262,11 +262,11 @@ public class SimpleElementValue extends ElementValue { switch (type) { case PRIMITIVE_INT: ConstantInteger c = (ConstantInteger) cpool.getConstant(idx); - s.append("(int)").append(Integer.toString(c.getValue())); + s.append("(int)").append(c.getValue()); break; case PRIMITIVE_LONG: ConstantLong j = (ConstantLong) cpool.getConstant(idx); - s.append("(long)").append(Long.toString(j.getValue())); + s.append("(long)").append(j.getValue()); break; case PRIMITIVE_DOUBLE: ConstantDouble d = (ConstantDouble) cpool.getConstant(idx); @@ -274,19 +274,19 @@ public class SimpleElementValue extends ElementValue { break; case PRIMITIVE_FLOAT: ConstantFloat f = (ConstantFloat) cpool.getConstant(idx); - s.append("(float)").append(Float.toString(f.getValue())); + s.append("(float)").append(f.getValue()); break; case PRIMITIVE_SHORT: ConstantInteger ci = (ConstantInteger) cpool.getConstant(idx); - s.append("(short)").append(Integer.toString(ci.getValue())); + s.append("(short)").append(ci.getValue()); break; case PRIMITIVE_BYTE: ConstantInteger b = (ConstantInteger) cpool.getConstant(idx); - s.append("(byte)").append(Integer.toString(b.getValue())); + s.append("(byte)").append(b.getValue()); break; case PRIMITIVE_CHAR: ConstantInteger ch = (ConstantInteger) cpool.getConstant(idx); - s.append("(char)").append(new Character((char) ch.getIntValue()).toString()); + s.append("(char)").append((char) ch.getIntValue()); break; case PRIMITIVE_BOOLEAN: ConstantInteger bo = (ConstantInteger) cpool.getConstant(idx); diff --git a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java index 5fe956790..62c1b3bd7 100644 --- a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java +++ b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java @@ -201,7 +201,7 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase { checkValue(ann,"dval","33.4"); checkValue(ann,"sval","99"); checkValue(ann,"bval","2"); - checkValue(ann,"cval",new Character('5').toString()); + checkValue(ann,"cval", Character.toString('5')); checkValue(ann,"zval","false"); } diff --git a/bridge/src/main/java/org/aspectj/bridge/ReflectionFactory.java b/bridge/src/main/java/org/aspectj/bridge/ReflectionFactory.java index 8eb65b3a0..73f063dc4 100644 --- a/bridge/src/main/java/org/aspectj/bridge/ReflectionFactory.java +++ b/bridge/src/main/java/org/aspectj/bridge/ReflectionFactory.java @@ -47,7 +47,7 @@ public class ReflectionFactory { // XXX lease, pool final Class<?> cfn = Class.forName(cname); String error = null; if (args == NONE) { - result = cfn.newInstance(); + result = cfn.getDeclaredConstructor().newInstance(); } else { Class<?>[] types = getTypes(args); Constructor<?> constructor = cfn.getConstructor(types); diff --git a/build/src/main/java/$installer$/org/aspectj/Main.java b/build/src/main/java/$installer$/org/aspectj/Main.java index f75f28a6e..a307be930 100644 --- a/build/src/main/java/$installer$/org/aspectj/Main.java +++ b/build/src/main/java/$installer$/org/aspectj/Main.java @@ -145,7 +145,7 @@ public class Main { try { String className = (String) properties.get("installer.main.class"); //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - Installer installer = (Installer) Class.forName(className).newInstance(); + Installer installer = (Installer) Class.forName(className).getDeclaredConstructor().newInstance(); InstallContext installerContext = new InstallContext(properties); installerContext.setHasGui(hasGui); installer.setContext(installerContext); diff --git a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java index 31ed76201..82edad5ea 100644 --- a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java +++ b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java @@ -599,7 +599,7 @@ public class AntBuilder extends Builder { ClassLoader parent = Task.class.getClassLoader(); ClassLoader loader = new URLClassLoader(cp, parent); Class c = loader.loadClass(AJCTASK); - task = c.newInstance(); + task = c.getDeclaredConstructor().newInstance(); // Westodo Project project = javac.getProject(); Method m = c.getMethod("setupAjc", new Class[] { Javac.class }); m.invoke(task, new Object[] { javac }); @@ -825,4 +825,4 @@ class ProjectMessager extends Messager { return true; } -}
\ No newline at end of file +} diff --git a/loadtime/src/main/java/org/aspectj/weaver/loadtime/Options.java b/loadtime/src/main/java/org/aspectj/weaver/loadtime/Options.java index e76f60e7c..1577ffc21 100644 --- a/loadtime/src/main/java/org/aspectj/weaver/loadtime/Options.java +++ b/loadtime/src/main/java/org/aspectj/weaver/loadtime/Options.java @@ -65,7 +65,7 @@ public class Options { String handlerClass = arg.substring(OPTIONVALUED_messageHandler.length()).trim(); try { Class<?> handler = Class.forName(handlerClass, false, laoder); - weaverOption.messageHandler = ((IMessageHandler) handler.newInstance()); + weaverOption.messageHandler = ((IMessageHandler) handler.getDeclaredConstructor().newInstance()); } catch (Throwable t) { weaverOption.messageHandler.handleMessage(new Message("Cannot instantiate message handler " + handlerClass, IMessage.ERROR, t, null)); diff --git a/loadtime/src/main/java/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java b/loadtime/src/main/java/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java index 9ee650dc6..f0773c0ed 100644 --- a/loadtime/src/main/java/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java +++ b/loadtime/src/main/java/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java @@ -98,13 +98,10 @@ public class WeavingURLClassLoader extends ExtensibleURLClassLoader implements W File f = new File(t.nextToken().trim()); try { if (f.exists()) { - URL url = f.toURL(); - if (url != null) { + URL url = f.toURI().toURL(); urlList.add(url); } - } - } catch (MalformedURLException e) { - } + } catch (MalformedURLException ignored) {} } URL[] urls = new URL[urlList.size()]; diff --git a/loadtime/src/test/java/org/aspectj/weaver/loadtime/JRockitAgentTest.java b/loadtime/src/test/java/org/aspectj/weaver/loadtime/JRockitAgentTest.java index 4c37d568b..223f66fbb 100644 --- a/loadtime/src/test/java/org/aspectj/weaver/loadtime/JRockitAgentTest.java +++ b/loadtime/src/test/java/org/aspectj/weaver/loadtime/JRockitAgentTest.java @@ -112,7 +112,7 @@ public class JRockitAgentTest extends TestCase { } Class agentClazz = Class.forName("org.aspectj.weaver.loadtime.JRockitAgent", false, this); - Object obj = agentClazz.newInstance(); + Object obj = agentClazz.getDeclaredConstructor().newInstance(); if (debug) System.out.println("JRockitClassLoader.JRockitClassLoader() obj=" + obj); this.agent = obj; @@ -130,7 +130,7 @@ public class JRockitAgentTest extends TestCase { String escaped = s.substring(i + 1, i + 3); s = s.substring(i + 3); Integer value = Integer.valueOf(escaped, 16); - result.append(new Character((char) value.intValue())); + result.append(Character.valueOf((char) value.intValue())); i = s.indexOf("%"); } result.append(s); diff --git a/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingContextTest.java b/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingContextTest.java index 9ef64a04b..98ecf1bae 100644 --- a/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingContextTest.java +++ b/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingContextTest.java @@ -84,7 +84,7 @@ public class WeavingContextTest extends TestCase { public void testGetFile() throws IOException { File file = new File("../loadtime/testdata"); - URL fileURL = file.getCanonicalFile().toURL(); + URL fileURL = file.getCanonicalFile().toURI().toURL(); URLClassLoader loader = new URLClassLoader(new URL[] { fileURL },null); IWeavingContext context = new TestWeavingContext(loader) { @@ -102,7 +102,7 @@ public class WeavingContextTest extends TestCase { public void testGetId() throws IOException { File file = new File("../loadtime/testdata"); - URL fileURL = file.getCanonicalFile().toURL(); + URL fileURL = file.getCanonicalFile().toURI().toURL(); URLClassLoader loader = new URLClassLoader(new URL[] { fileURL },null); IWeavingContext context = new TestWeavingContext(loader) { @@ -120,7 +120,7 @@ public class WeavingContextTest extends TestCase { public void testGetDefinitions () throws Exception { File file = new File("../loadtime/testdata"); - URL fileURL = file.getCanonicalFile().toURL(); + URL fileURL = file.getCanonicalFile().toURI().toURL(); URLClassLoader loader = new URLClassLoader(new URL[] { fileURL },null); IWeavingContext context = new TestWeavingContext(loader) { diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjPipeliningCompilerAdapter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjPipeliningCompilerAdapter.java index e576ee0d3..eb6bb92da 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjPipeliningCompilerAdapter.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjPipeliningCompilerAdapter.java @@ -229,7 +229,7 @@ public class AjPipeliningCompilerAdapter extends AbstractCompilerAdapter { if (pipelineOutput == null) { pipelineOutput = new Hashtable(); } - pipelineOutput.put("filesContainingAspects", new Integer(toWaitFor).toString()); + pipelineOutput.put("filesContainingAspects", Integer.toString(toWaitFor)); StringBuffer order = new StringBuffer(); order.append("["); for (int i = 0; i < units.length; i++) { diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java index a8c3f5a44..c326c0a69 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java @@ -898,7 +898,7 @@ public abstract class AjcTestCase extends TestCase { URL[] urls = new URL[strTok.countTokens()]; try { for (int i = 0; i < urls.length; i++) { - urls[i] = new File(strTok.nextToken()).getCanonicalFile().toURL(); + urls[i] = new File(strTok.nextToken()).getCanonicalFile().toURI().toURL(); } } catch (Exception malEx) { fail("Bad classpath specification: " + classpath); diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/SimpleAnnotationValue.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/SimpleAnnotationValue.java index 32e55f6b4..2fe37e2cb 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/SimpleAnnotationValue.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/SimpleAnnotationValue.java @@ -84,7 +84,7 @@ public class SimpleAnnotationValue extends AnnotationValue { case 'B': // byte return Byte.toString(theByte); case 'C': // char - return new Character(theChar).toString(); + return Character.toString(theChar); case 'D': // double return Double.toString(theDouble); case 'F': // float diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateFactory.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateFactory.java index 9edf23f8f..a56950261 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateFactory.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateFactory.java @@ -69,7 +69,7 @@ public class ReflectionBasedReferenceTypeDelegateFactory { ClassLoader usingClassLoader, World inWorld) { try { Class delegateClass = Class.forName("org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate"); - ReflectionBasedReferenceTypeDelegate ret = (ReflectionBasedReferenceTypeDelegate) delegateClass.newInstance(); + ReflectionBasedReferenceTypeDelegate ret = (ReflectionBasedReferenceTypeDelegate) delegateClass.getDeclaredConstructor().newInstance(); ret.initialize(forReferenceType, forClass, usingClassLoader, inWorld); return ret; } catch (ClassNotFoundException cnfEx) { @@ -81,6 +81,12 @@ public class ReflectionBasedReferenceTypeDelegateFactory { } catch (IllegalAccessException illAccEx) { throw new IllegalStateException("Attempted to create Java 1.5 reflection based delegate but IllegalAccessException: " + illAccEx + " occured"); + } catch (NoSuchMethodException nsMethEx) { + throw new IllegalStateException("Attempted to create Java 1.5 reflection based delegate but NoSuchMethodException: " + + nsMethEx + " occured"); + } catch (InvocationTargetException invTargEx) { + throw new IllegalStateException("Attempted to create Java 1.5 reflection based delegate but InvocationTargetException: " + + invTargEx + " occured"); } } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionWorld.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionWorld.java index e3e19e64b..464aba367 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionWorld.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionWorld.java @@ -8,6 +8,7 @@ * ******************************************************************/ package org.aspectj.weaver.reflect; +import java.lang.reflect.InvocationTargetException; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -116,16 +117,17 @@ public class ReflectionWorld extends World implements IReflectionWorld { AnnotationFinder annotationFinder = null; try { Class<?> java15AnnotationFinder = Class.forName("org.aspectj.weaver.reflect.Java15AnnotationFinder"); - annotationFinder = (AnnotationFinder) java15AnnotationFinder.newInstance(); + annotationFinder = (AnnotationFinder) java15AnnotationFinder.getDeclaredConstructor().newInstance(); annotationFinder.setClassLoader(loader); annotationFinder.setWorld(world); } catch (ClassNotFoundException ex) { // must be on 1.4 or earlier - } catch (IllegalAccessException ex) { + } catch (IllegalAccessException | InstantiationException | NoSuchMethodException ex) { // not so good throw new BCException("AspectJ internal error", ex); - } catch (InstantiationException ex) { - throw new BCException("AspectJ internal error", ex); + } + catch (InvocationTargetException e) { + e.printStackTrace(); } return annotationFinder; } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/AbstractTrace.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/AbstractTrace.java index fe2f86f54..bca1985e7 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/AbstractTrace.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/AbstractTrace.java @@ -68,7 +68,7 @@ public abstract class AbstractTrace implements Trace { @Override public void exit (String methodName, int i) { - exit(methodName,new Integer(i)); + exit(methodName, Integer.valueOf(i)); } @Override @@ -210,4 +210,4 @@ public abstract class AbstractTrace implements Trace { return args; } -}
\ No newline at end of file +} diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/TraceFactory.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/TraceFactory.java index 3fc92f5b4..8190d67a3 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/TraceFactory.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/TraceFactory.java @@ -45,7 +45,7 @@ public abstract class TraceFactory { } else { Class factoryClass = Class.forName(factoryName); - instance = (TraceFactory)factoryClass.newInstance(); + instance = (TraceFactory)factoryClass.getDeclaredConstructor().newInstance(); } } catch (Throwable th) { @@ -58,7 +58,7 @@ public abstract class TraceFactory { if (instance == null) try { { Class factoryClass = Class.forName("org.aspectj.weaver.tools.Jdk14TraceFactory"); - instance = (TraceFactory)factoryClass.newInstance(); + instance = (TraceFactory)factoryClass.getDeclaredConstructor().newInstance(); } } catch (Throwable th) { diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/PatternsTestCase.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/PatternsTestCase.java index 62a3c0566..82c1dc35c 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/PatternsTestCase.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/PatternsTestCase.java @@ -24,7 +24,7 @@ public abstract class PatternsTestCase extends TestCase { public URLClassLoader getClassLoaderForFile(File f) { try { - URLClassLoader ucl = new URLClassLoader(new URL[] { f.toURL() }, this.getClass().getClassLoader()); + URLClassLoader ucl = new URLClassLoader(new URL[] { f.toURI().toURL() }, this.getClass().getClassLoader()); return ucl; } catch (MalformedURLException mue) { throw new RuntimeException(mue); diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java index a48769ecb..a4415833a 100644 --- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java +++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java @@ -287,7 +287,7 @@ public class AjcTask extends MatchingTask { if (null != editorClassName) { ClassLoader cl = AjcTask.class.getClassLoader(); Class editorClass = cl.loadClass(editorClassName); - editor = (ICommandEditor) editorClass.newInstance(); + editor = (ICommandEditor) editorClass.getDeclaredConstructor().newInstance(); } } catch (Throwable t) { System.err.println("Warning: unable to load command editor"); @@ -865,7 +865,7 @@ public class AjcTask extends MatchingTask { public void setMessageHolderClass(String className) { try { Class mclass = Class.forName(className); - IMessageHolder holder = (IMessageHolder) mclass.newInstance(); + IMessageHolder holder = (IMessageHolder) mclass.getDeclaredConstructor().newInstance(); setMessageHolder(holder); } catch (Throwable t) { String m = "unable to instantiate message holder: " + className; @@ -889,7 +889,7 @@ public class AjcTask extends MatchingTask { public void setCommandEditorClass(String className) { // skip Ant interface? try { Class mclass = Class.forName(className); - setCommandEditor((ICommandEditor) mclass.newInstance()); + setCommandEditor((ICommandEditor) mclass.getDeclaredConstructor().newInstance()); } catch (Throwable t) { String m = "unable to instantiate command editor: " + className; throw new BuildException(m, t); diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java index a3bcbd91a..fe6900755 100644 --- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java +++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java @@ -92,7 +92,7 @@ public class Ajc extends DefaultCompilerAdapter { System.setErr(logstr); return (Integer) main.getMethod ("compile", new Class[]{String[].class}).invoke - (main.newInstance(), new Object[]{ + (main.getDeclaredConstructor().newInstance(), new Object[]{ removeUnsupported(cline, logstr) }) == AJC_COMPILER_SUCCESS; } catch (Exception e) { diff --git a/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java b/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java index ddd6a7caf..79ae9a776 100644 --- a/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java +++ b/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java @@ -40,13 +40,12 @@ import org.aspectj.util.Reflection; import jdiff.text.FileLine; import jdiff.util.Diff; import jdiff.util.DiffNormalOutput; -import junit.framework.Assert; +import org.junit.Assert; import junit.framework.AssertionFailedError; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestResult; import junit.framework.TestSuite; -import sun.net.www.ParseUtil; /** * Things that junit should perhaps have, but doesn't. Note the file-comparison methods require JDiff to run, but JDiff types are @@ -163,7 +162,7 @@ public final class TestUtil { public static URL fileToURL(File file) { try { - return file.toURL(); + return file.toURI().toURL(); } catch (MalformedURLException e) { return null; } @@ -303,7 +302,7 @@ public final class TestUtil { public static URL libURL(String rpath) { File file = libFile(rpath); try { - return file.toURL(); + return file.toURI().toURL(); } catch (MalformedURLException e) { throw new IllegalArgumentException("bad URL from: " + file); } diff --git a/testing/src/test/java/org/aspectj/testing/AutowiredXMLBasedAjcTestCase.java b/testing/src/test/java/org/aspectj/testing/AutowiredXMLBasedAjcTestCase.java index ca9a7f431..a0314017b 100644 --- a/testing/src/test/java/org/aspectj/testing/AutowiredXMLBasedAjcTestCase.java +++ b/testing/src/test/java/org/aspectj/testing/AutowiredXMLBasedAjcTestCase.java @@ -53,7 +53,7 @@ public abstract class AutowiredXMLBasedAjcTestCase extends XMLBasedAjcTestCase { // wire the spec file try { - final AutowiredXMLBasedAjcTestCase wired = (AutowiredXMLBasedAjcTestCase) testCaseClass.newInstance(); + final AutowiredXMLBasedAjcTestCase wired = (AutowiredXMLBasedAjcTestCase) testCaseClass.getDeclaredConstructor().newInstance(); System.out.println("LOADING SUITE: " + wired.getSpecFile().getPath()); Digester d = wired.getDigester(); try { diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcSpecTest.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcSpecTest.java index 2ff173362..5adf128e3 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcSpecTest.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcSpecTest.java @@ -13,7 +13,6 @@ package org.aspectj.testing.harness.bridge; -import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; diff --git a/testing/src/test/java/org/aspectj/testing/util/options/OptionChecker.java b/testing/src/test/java/org/aspectj/testing/util/options/OptionChecker.java index 79d1ff286..6c30f97b1 100644 --- a/testing/src/test/java/org/aspectj/testing/util/options/OptionChecker.java +++ b/testing/src/test/java/org/aspectj/testing/util/options/OptionChecker.java @@ -16,7 +16,7 @@ import java.util.Arrays; import org.aspectj.testing.util.LangUtil; -import junit.framework.Assert; +import org.junit.Assert; /** * Drivers to test a given set of Options. diff --git a/testing/src/test/java/org/aspectj/testing/util/options/OptionsTest.java b/testing/src/test/java/org/aspectj/testing/util/options/OptionsTest.java index 5c380d739..f0f4f066c 100644 --- a/testing/src/test/java/org/aspectj/testing/util/options/OptionsTest.java +++ b/testing/src/test/java/org/aspectj/testing/util/options/OptionsTest.java @@ -14,7 +14,7 @@ package org.aspectj.testing.util.options; import org.aspectj.testing.util.options.Option.InvalidInputException; -import junit.framework.Assert; +import org.junit.Assert; import junit.framework.TestCase; /** diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/GenericsTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/GenericsTests.java index ee6fb6af6..8bb04f389 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc150/GenericsTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/GenericsTests.java @@ -882,7 +882,7 @@ public class GenericsTests extends XMLBasedAjcTestCase { Set<String> methodsFound = new HashSet<>(); StringBuffer debugString = new StringBuffer(); try { - ClassLoader cl = new URLClassLoader(new URL[]{ajc.getSandboxDirectory().toURL()}); + ClassLoader cl = new URLClassLoader(new URL[]{ajc.getSandboxDirectory().toURI().toURL()}); Class<?> clz = Class.forName(classname,false,cl); java.lang.reflect.Method[] ms = clz.getDeclaredMethods(); if (ms!=null) { diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc186/Ajc186Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc186/Ajc186Tests.java index 379c54333..be324c279 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc186/Ajc186Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc186/Ajc186Tests.java @@ -105,7 +105,7 @@ public class Ajc186Tests extends org.aspectj.testing.XMLBasedAjcTestCase { URLClassLoader ucl = new URLClassLoader(new URL[] {ajc.getSandboxDirectory().toURI().toURL()},this.getClass().getClassLoader()); Class<?> applicationClass = Class.forName("Application",false,ucl); assertNotNull(applicationClass); - Object instance = applicationClass.newInstance(); + Object instance = applicationClass.getDeclaredConstructor().newInstance(); Method works = applicationClass.getDeclaredMethod("fromInnerClass"); works.setAccessible(true); Runnable r = (Runnable) works.invoke(instance); diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc190/EfficientTJPTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc190/EfficientTJPTests.java index 2f01d0d97..726987f34 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc190/EfficientTJPTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc190/EfficientTJPTests.java @@ -11,7 +11,7 @@ import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.Method; import org.aspectj.testing.XMLBasedAjcTestCase; -import junit.framework.Assert; +import org.junit.Assert; import junit.framework.Test; /** diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/LazyClassGen.java b/weaver/src/main/java/org/aspectj/weaver/bcel/LazyClassGen.java index f2e61c565..5e72d84ce 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/LazyClassGen.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/LazyClassGen.java @@ -280,7 +280,7 @@ public final class LazyClassGen { } public String getNewGeneratedNameTag() { - return new Integer(childCounter++).toString(); + return Integer.toString(childCounter++); } // ---- diff --git a/weaver/src/main/java/org/aspectj/weaver/ltw/LTWWorld.java b/weaver/src/main/java/org/aspectj/weaver/ltw/LTWWorld.java index 077a91943..ca4779526 100644 --- a/weaver/src/main/java/org/aspectj/weaver/ltw/LTWWorld.java +++ b/weaver/src/main/java/org/aspectj/weaver/ltw/LTWWorld.java @@ -11,6 +11,7 @@ * ******************************************************************/ package org.aspectj.weaver.ltw; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -179,10 +180,8 @@ public class LTWWorld extends BcelWorld implements IReflectionWorld { private static Map makeConcurrentMap() { if (concurrentMapClass != null) { try { - return (Map) concurrentMapClass.newInstance(); - } catch (InstantiationException ie) { - } catch (IllegalAccessException iae) { - } + return (Map) concurrentMapClass.getDeclaredConstructor().newInstance(); + } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException ignored) {} // fall through if exceptions } return Collections.synchronizedMap(new HashMap()); diff --git a/weaver/src/test/java/org/aspectj/weaver/bcel/ClassLoaderRepositoryTest.java b/weaver/src/test/java/org/aspectj/weaver/bcel/ClassLoaderRepositoryTest.java index 42c5189a4..cef1f7c90 100644 --- a/weaver/src/test/java/org/aspectj/weaver/bcel/ClassLoaderRepositoryTest.java +++ b/weaver/src/test/java/org/aspectj/weaver/bcel/ClassLoaderRepositoryTest.java @@ -49,7 +49,7 @@ public class ClassLoaderRepositoryTest extends TestCase { private ClassLoaderRepository setupRepository() throws Exception { ClassLoader cl = Thread.currentThread().getContextClassLoader(); - ClassLoader res = new URLClassLoader(new URL[]{f.toURL()},cl); + ClassLoader res = new URLClassLoader(new URL[]{f.toURI().toURL()},cl); ClassLoaderRepository rep = new ClassLoaderRepository(res); return rep; } diff --git a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java index 6e4ffa9f6..d3eaaf67e 100644 --- a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java +++ b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java @@ -21,7 +21,7 @@ import org.aspectj.weaver.patterns.PatternParser; import org.aspectj.weaver.patterns.Pointcut; import org.aspectj.weaver.patterns.PointcutRewriter; -import junit.framework.Assert; +import org.junit.Assert; import junit.framework.TestCase; /** |