aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/compiler/MemberCodeGen.java
diff options
context:
space:
mode:
authorSam Ma <samuel.ma2012@gmail.com>2019-03-20 13:08:43 +1100
committerSam Ma <samuel.ma2012@gmail.com>2019-03-20 13:08:43 +1100
commite71398c6fc652b8c522da858906a4385cf102130 (patch)
tree8a20ab1b19dc6b404936f5d88c6d3fd7b6b36790 /src/main/javassist/compiler/MemberCodeGen.java
parenteff2f4bbd0246476edfa43782f38e58ddedef952 (diff)
downloadjavassist-e71398c6fc652b8c522da858906a4385cf102130.tar.gz
javassist-e71398c6fc652b8c522da858906a4385cf102130.zip
Fix #252 make instrumentation works on JDK11 for the inner class which has access to the private constructor of the host class
Diffstat (limited to 'src/main/javassist/compiler/MemberCodeGen.java')
-rw-r--r--src/main/javassist/compiler/MemberCodeGen.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/main/javassist/compiler/MemberCodeGen.java b/src/main/javassist/compiler/MemberCodeGen.java
index ad254816..25be0ee1 100644
--- a/src/main/javassist/compiler/MemberCodeGen.java
+++ b/src/main/javassist/compiler/MemberCodeGen.java
@@ -636,8 +636,22 @@ public class MemberCodeGen extends CodeGen {
throw new CompileError("no such constructor: " + targetClass.getName());
if (declClass != thisClass && AccessFlag.isPrivate(acc)) {
- desc = getAccessibleConstructor(desc, declClass, minfo);
- bytecode.addOpcode(Opcode.ACONST_NULL); // the last parameter
+ boolean isNested = false;
+ if (declClass.getClassFile().getMajorVersion() >= ClassFile.JAVA_11) {
+ try {
+ CtClass[] nestedClasses = declClass.getNestedClasses();
+ for (int i = 0; i < nestedClasses.length; i++) {
+ if (thisClass == nestedClasses[i]) {
+ isNested = true;
+ break;
+ }
+ }
+ } catch (NotFoundException ignored) { }
+ }
+ if (!isNested) {
+ desc = getAccessibleConstructor(desc, declClass, minfo);
+ bytecode.addOpcode(Opcode.ACONST_NULL); // the last parameter
+ }
}
}
else if (AccessFlag.isPrivate(acc))