aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok
diff options
context:
space:
mode:
authorReinier Zwitserloot <r.zwitserloot@projectlombok.org>2019-05-06 21:26:29 +0200
committerReinier Zwitserloot <r.zwitserloot@projectlombok.org>2019-05-06 21:26:29 +0200
commitd41e804fe73faed5f8b90f4b472728bc3a0c85b7 (patch)
treef47d82c4f383cfdb242c803c88eadde5c2982944 /src/core/lombok
parent2335f251665d43b4c8cebe00b980f07ef33bdb17 (diff)
downloadlombok-d41e804fe73faed5f8b90f4b472728bc3a0c85b7.tar.gz
lombok-d41e804fe73faed5f8b90f4b472728bc3a0c85b7.tar.bz2
lombok-d41e804fe73faed5f8b90f4b472728bc3a0c85b7.zip
[trivial] replacing all calls to Class.newInstance() with Class.getConstructor().newInstance to avoid warnings which are default in many JDK11+ environments, and it shouldn’t change anything (we handle the change from sneaky throwing to InvocationTargetException appropriately).
Diffstat (limited to 'src/core/lombok')
-rw-r--r--src/core/lombok/core/AgentLauncher.java4
-rw-r--r--src/core/lombok/core/AnnotationProcessor.java2
2 files changed, 4 insertions, 2 deletions
diff --git a/src/core/lombok/core/AgentLauncher.java b/src/core/lombok/core/AgentLauncher.java
index 1d5ab3e6..5b5af7ba 100644
--- a/src/core/lombok/core/AgentLauncher.java
+++ b/src/core/lombok/core/AgentLauncher.java
@@ -22,6 +22,7 @@
package lombok.core;
import java.lang.instrument.Instrumentation;
+import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -35,9 +36,10 @@ public class AgentLauncher {
for (AgentInfo info : AGENTS) {
try {
Class<?> agentClass = Class.forName(info.className());
- AgentLaunchable agent = (AgentLaunchable) agentClass.newInstance();
+ AgentLaunchable agent = (AgentLaunchable) agentClass.getConstructor().newInstance();
agent.runAgent(agentArgs, instrumentation, injected, launchingContext);
} catch (Throwable t) {
+ if (t instanceof InvocationTargetException) t = t.getCause();
info.problem(t, instrumentation);
}
}
diff --git a/src/core/lombok/core/AnnotationProcessor.java b/src/core/lombok/core/AnnotationProcessor.java
index 363952a4..46e3b1af 100644
--- a/src/core/lombok/core/AnnotationProcessor.java
+++ b/src/core/lombok/core/AnnotationProcessor.java
@@ -112,7 +112,7 @@ public class AnnotationProcessor extends AbstractProcessor {
try {
ClassLoader classLoader = findAndPatchClassLoader(javacProcEnv);
- processor = (Processor) Class.forName("lombok.javac.apt.LombokProcessor", false, classLoader).newInstance();
+ processor = (Processor) Class.forName("lombok.javac.apt.LombokProcessor", false, classLoader).getConstructor().newInstance();
} catch (Exception e) {
delayedWarnings.add("You found a bug in lombok; lombok.javac.apt.LombokProcessor is not available. Lombok will not run during this compilation: " + trace(e));
return false;