diff options
author | Shigeru Chiba <chibash@users.noreply.github.com> | 2019-09-02 00:27:11 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-02 00:27:11 +0900 |
commit | bad4a16db3df4fb2a6b5567d1edce1d17c7d1683 (patch) | |
tree | 225738668e8e0ef195bfe91d5322dc0adab1b79b /src/main/javassist | |
parent | cf1d22fa1f2554df07801291b98f84c627fc9ef5 (diff) | |
parent | d6d6b2e959d3758f69b2917587b16453d7fc6ec5 (diff) | |
download | javassist-bad4a16db3df4fb2a6b5567d1edce1d17c7d1683.tar.gz javassist-bad4a16db3df4fb2a6b5567d1edce1d17c7d1683.zip |
Merge pull request #267 from sam-ma/master
Fix #265 javassist.CannotCompileException: [source error] the called …
Diffstat (limited to 'src/main/javassist')
-rw-r--r-- | src/main/javassist/compiler/MemberCodeGen.java | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/main/javassist/compiler/MemberCodeGen.java b/src/main/javassist/compiler/MemberCodeGen.java index 25be0ee1..f1ec84a5 100644 --- a/src/main/javassist/compiler/MemberCodeGen.java +++ b/src/main/javassist/compiler/MemberCodeGen.java @@ -619,6 +619,18 @@ public class MemberCodeGen extends CodeGen { aload0pos, found); } + private boolean isFromSameDeclaringClass(CtClass outer, CtClass inner) { + try { + while (outer != null) { + if (isEnclosing(outer, inner)) + return true; + outer = outer.getDeclaringClass(); + } + } + catch (NotFoundException e) {} + return false; + } + private void atMethodCallCore2(CtClass targetClass, String mname, boolean isStatic, boolean isSpecial, int aload0pos, @@ -636,19 +648,8 @@ public class MemberCodeGen extends CodeGen { throw new CompileError("no such constructor: " + targetClass.getName()); if (declClass != thisClass && AccessFlag.isPrivate(acc)) { - 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) { + if (declClass.getClassFile().getMajorVersion() < ClassFile.JAVA_11 + || !isFromSameDeclaringClass(declClass, thisClass)) { desc = getAccessibleConstructor(desc, declClass, minfo); bytecode.addOpcode(Opcode.ACONST_NULL); // the last parameter } |