From aa5c04a2b5c7fc6d71a257b19952f8817e828706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20=C3=81lvarez=20=C3=81lvarez?= Date: Fri, 23 Feb 2024 07:21:24 +0100 Subject: [PATCH] Fix issue simple lazy resolution with valid leading characters (#1599) --- .../bytebuddy/description/type/TypeDescription.java | 2 +- ...lDefaultWithLazyResolutionTypeDescriptionTest.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/byte-buddy-dep/src/main/java/net/bytebuddy/description/type/TypeDescription.java b/byte-buddy-dep/src/main/java/net/bytebuddy/description/type/TypeDescription.java index 8b96d13b1d3..a3ec02597c2 100644 --- a/byte-buddy-dep/src/main/java/net/bytebuddy/description/type/TypeDescription.java +++ b/byte-buddy-dep/src/main/java/net/bytebuddy/description/type/TypeDescription.java @@ -8408,7 +8408,7 @@ public String getSimpleName() { return internalName; } } - while (simpleNameIndex < internalName.length() && !Character.isLetter(internalName.charAt(simpleNameIndex))) { + while (simpleNameIndex < internalName.length() && !Character.isJavaIdentifierStart(internalName.charAt(simpleNameIndex))) { simpleNameIndex += 1; } return internalName.substring(simpleNameIndex); diff --git a/byte-buddy-dep/src/test/java/net/bytebuddy/pool/TypePoolDefaultWithLazyResolutionTypeDescriptionTest.java b/byte-buddy-dep/src/test/java/net/bytebuddy/pool/TypePoolDefaultWithLazyResolutionTypeDescriptionTest.java index f42a813cc42..2cd8fe193bc 100644 --- a/byte-buddy-dep/src/test/java/net/bytebuddy/pool/TypePoolDefaultWithLazyResolutionTypeDescriptionTest.java +++ b/byte-buddy-dep/src/test/java/net/bytebuddy/pool/TypePoolDefaultWithLazyResolutionTypeDescriptionTest.java @@ -224,6 +224,13 @@ public void testGenericSuperInterfaceNavigatedHierarchyResolutionIsLazy() throws verifyNoMoreInteractions(classFileLocator); } + @Test + @Override + public void testSimpleName() throws Exception { + super.testSimpleName(); + assertThat(describe($DollarInName.class).getSimpleName(), CoreMatchers.is($DollarInName.class.getSimpleName())); + } + private static class SuperClass { /* empty */ } @@ -265,4 +272,8 @@ T foo(T argument) throws T { return argument; } } + + private static class $DollarInName { + /* empty */ + } }