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 /loadtime | |
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>
Diffstat (limited to 'loadtime')
4 files changed, 8 insertions, 11 deletions
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) { |