diff --git a/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/scaffold/TypeWriter.java b/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/scaffold/TypeWriter.java index 13befc6318a..cc507235d15 100644 --- a/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/scaffold/TypeWriter.java +++ b/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/scaffold/TypeWriter.java @@ -4154,8 +4154,8 @@ protected void onVisitEnd() { typeDescription.getSimpleName(), typeDescription.getModifiers()); } - MethodDescription.InDefinedShape outerMethod = instrumentedType.getEnclosingMethod(); - if (outerMethod != null) { + MethodDescription.InDefinedShape enclosingMethod = instrumentedType.getEnclosingMethod(); + if (enclosingMethod != null) { cv.visitInnerClass(instrumentedType.getInternalName(), NO_REFERENCE, instrumentedType.isAnonymousType() @@ -4163,13 +4163,11 @@ protected void onVisitEnd() { : instrumentedType.getSimpleName(), instrumentedType.getModifiers()); } else { - TypeDescription outerType = instrumentedType.getDeclaringType() == null - ? instrumentedType.getDeclaringType() - : instrumentedType.getEnclosingType(); - if (outerType != null) { + TypeDescription declaringType = instrumentedType.getDeclaringType(); + if (declaringType != null) { cv.visitInnerClass(instrumentedType.getInternalName(), instrumentedType.isMemberType() - ? outerType.getInternalName() + ? declaringType.getInternalName() : NO_REFERENCE, instrumentedType.isAnonymousType() ? NO_REFERENCE @@ -4760,8 +4758,7 @@ protected UnresolvedType create(TypeInitializer typeInitializer) { typeDescription.getSimpleName(), typeDescription.getModifiers()); } - MethodDescription.InDefinedShape outerMethod = instrumentedType.getEnclosingMethod(); - if (outerMethod != null) { + if (enclosingMethod != null) { classVisitor.visitInnerClass(instrumentedType.getInternalName(), NO_REFERENCE, instrumentedType.isAnonymousType() @@ -4769,13 +4766,11 @@ protected UnresolvedType create(TypeInitializer typeInitializer) { : instrumentedType.getSimpleName(), instrumentedType.getModifiers()); } else { - TypeDescription outerType = instrumentedType.getDeclaringType() == null - ? instrumentedType.getDeclaringType() - : instrumentedType.getEnclosingType(); - if (outerType != null) { + TypeDescription declaringType = instrumentedType.getDeclaringType(); + if (declaringType != null) { classVisitor.visitInnerClass(instrumentedType.getInternalName(), instrumentedType.isMemberType() - ? outerType.getInternalName() + ? declaringType.getInternalName() : NO_REFERENCE, instrumentedType.isAnonymousType() ? NO_REFERENCE diff --git a/byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/AbstractDynamicTypeBuilderTest.java b/byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/AbstractDynamicTypeBuilderTest.java index aea99763967..2282191c683 100644 --- a/byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/AbstractDynamicTypeBuilderTest.java +++ b/byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/AbstractDynamicTypeBuilderTest.java @@ -1210,8 +1210,8 @@ public String getSimpleName() { .load(getClass().getClassLoader(), ClassLoadingStrategy.Default.CHILD_FIRST.opened()) .getLoaded(); Class type = createPlainWithoutValidation() - .innerTypeOf(outer) .name(sample.getName()) + .innerTypeOf(outer) .make() .load((InjectionClassLoader) outer.getClassLoader(), InjectionClassLoader.Strategy.INSTANCE) .getLoaded(); @@ -1271,8 +1271,8 @@ public String getSimpleName() { .load(getClass().getClassLoader(), ClassLoadingStrategy.Default.CHILD_FIRST.opened()) .getLoaded(); Class type = createPlainWithoutValidation() - .innerTypeOf(outer.getConstructor()) .name(sample.getName()) + .innerTypeOf(outer.getConstructor()) .make() .load((InjectionClassLoader) outer.getClassLoader(), InjectionClassLoader.Strategy.INSTANCE) .getLoaded(); @@ -1316,8 +1316,8 @@ public void visit(int version, int access, String name, String signature, String }; } }) - .nestHost(outer) .name(sample.getName()) + .nestHost(outer) .make() .load((InjectionClassLoader) outer.getClassLoader(), InjectionClassLoader.Strategy.INSTANCE) .getLoaded();