aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Gavrilovic <gavra@google.com>2019-04-16 15:14:16 -0700
committerIvan Gavrilovic <gavra@google.com>2019-04-16 15:14:16 -0700
commitc0527dfbea4b0d3f7868b53f9f9090f650f57459 (patch)
tree440018229229a9005ed91fcbd3cd4c012535c278
parente2a7708564791feead0ac8dd6a98f0fc14d622b2 (diff)
downloadjdk8u_langtools-c0527dfbea4b0d3f7868b53f9f9090f650f57459.tar.gz
Do not always try to load parameter names
In aosp/Idcca9709603a58da5f067ca32abe1b9f5dc45496 we switched to always loading all parameter names. However, this may cause issues when e.g. class <init> method is suppose to contain synthetic parameters but it does not. ClassReader will try to skip the synthetic params, but because they do not exist, NPE will occur. We work around this issue by restoring the previous behavior, which was to retrieve the param names only when saveParameterNames is true. There is one drawback though. Previously, if saveParameterNames was false, we would get invalid names (arg0, arg1...), but annotations would be correct. With this change, we will get invalid names without any annotations. However, annotation processing which is the primary user of these APIs always sets saveParameterNames to true, so there should not be any issues. Related to https://bugs.openjdk.java.net/browse/JDK-8177486
-rw-r--r--src/share/classes/com/sun/tools/javac/jvm/ClassReader.java3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
index 4ac08822..8430ac47 100644
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
@@ -2086,7 +2086,8 @@ public class ClassReader {
} finally {
currentOwner = prevOwner;
}
- setParameters(m, type);
+ if (saveParameterNames)
+ setParameters(m, type);
return m;
}