Skip to content

Commit

Permalink
Avoid stack overflow when type variables cannot be found.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphw committed Nov 23, 2022
1 parent d3145c8 commit c912dcf
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 16 deletions.
16 changes: 8 additions & 8 deletions .mvn/checksums.sha256
Original file line number Diff line number Diff line change
Expand Up @@ -543,14 +543,14 @@ log4j:log4j:pom:1.2.12 cb54dedc5d8c4510148dfa792701cbac1a84c383a84f48f5a32e6d7e4
log4j:log4j:pom:1.2.14 6c243babab94ee5fdc1b31d0c4fbb7ffeadf8373823532e0d03adb29f21406e3
logkit:logkit:pom:1.0.1 3de328dfa1b563ba6dfc5829774cf2f8dab0dc9528ed2731c35251ab7fd6c4c6
net.bytebuddy:byte-buddy-agent:jar:1.12.16 38e258787665ac95e4f42ff1ca5b7550093762d289a61d436a26b6a25386358e
net.bytebuddy:byte-buddy-agent:jar:1.12.18 c31a3256b2df60a5d227971798f73b5aa268a0cb854ecec39ffa6e372eecde21
net.bytebuddy:byte-buddy-android:jar:1.12.18 d8db100ea25d1d19d50d561deaebceac97982ed08ae9cd33ccfb5115aba1ee91
net.bytebuddy:byte-buddy-dep:jar:1.12.18 375658d62955da8602105778655b172b312da750d9c6c06a35abfdb1696746a4
net.bytebuddy:byte-buddy-maven-plugin:jar:1.12.18 b74422ead2bb4d2da47d5882cdc9cf9ac105cb31491ebff3de0c3d5ff7ba261d
net.bytebuddy:byte-buddy-maven-plugin:pom:1.12.18 c38bb62d6b7a2b351650863ab636be759ff676e258d8718d0e2cee2da3af307f
net.bytebuddy:byte-buddy-parent:pom:1.12.18 4ff888dbc1dfc7e232a21132bed3e19eb284c3948423a5f9ce95f30184367c31
net.bytebuddy:byte-buddy:jar:1.12.18 39200c13a72b6a3f4ec43c7b6d2fb78ecbeb25c29e986f4efa572636b39d750e
net.bytebuddy:byte-buddy:pom:1.12.18 7b4b21f812a83904e9c18145d38eaa55a3309c9c91febc6007ba06f4d50cf987
net.bytebuddy:byte-buddy-agent:jar:1.12.19 3a70240de7cdcde04e7c504c2327d7035b9c25ae0206881e3bf4e6798a273ed8
net.bytebuddy:byte-buddy-android:jar:1.12.19 bb73d3b9ace5a60a9a9aa1701761073b3df3baf79ff463aed6cd94b724fd3ba9
net.bytebuddy:byte-buddy-dep:jar:1.12.19 a85bb853ec6ec156b10ea0b5b0e38ac0f89c6c2bc89dd0358772a0dff2eb85c9
net.bytebuddy:byte-buddy-maven-plugin:jar:1.12.19 3419e2afbfac4f21ef709ee3f8f08fc1d71001e07ba2524a0bb2a3c28f3e1087
net.bytebuddy:byte-buddy-maven-plugin:pom:1.12.19 c2051f8cbdf328692f36077627be07168334ee9167b72e5bf608eae624163b4f
net.bytebuddy:byte-buddy-parent:pom:1.12.19 72ab6fef409e812921f4728b3c4b6ef4fa53bc25fabb0488fc2cae367368b54d
net.bytebuddy:byte-buddy:jar:1.12.19 030704139e46f32c38d27060edee9e0676b0a0fff8a8be53461515154ba8a7be
net.bytebuddy:byte-buddy:pom:1.12.19 435fb8664aa9b7e120c8dd6c707d4eafa642fa262dff6d5e3f71dc25c69e89eb
net.java.dev.jna:jna-platform:jar:5.12.1 8ce969116cac95bd61b07a8d5e07174b352e63301473caac72c395e3c08488d2
net.java.dev.jna:jna-platform:pom:5.12.1 c279ffa3b5168e2203087231c638919a7cec7458006b1cda66959747860fb457
net.java.dev.jna:jna:jar:5.12.1 91a814ac4f40d60dee91d842e1a8ad874c62197984403d0e3c30d39e55cf53b3
Expand Down
2 changes: 1 addition & 1 deletion byte-buddy-agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.12.18</version>
<version>1.12.19</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
12 changes: 6 additions & 6 deletions byte-buddy-dep/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
<plugin>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-maven-plugin</artifactId>
<version>1.12.18</version>
<version>1.12.19</version>
<executions>
<execution>
<phase>compile</phase>
Expand All @@ -142,7 +142,7 @@
<transformation>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.12.18</version>
<version>1.12.19</version>
<plugin>net.bytebuddy.build.HashCodeAndEqualsPlugin$WithNonNullableFields</plugin>
<arguments>
<argument>
Expand All @@ -154,13 +154,13 @@
<transformation>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.12.18</version>
<version>1.12.19</version>
<plugin>net.bytebuddy.build.CachedReturnPlugin</plugin>
</transformation>
<transformation>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.12.18</version>
<version>1.12.19</version>
<plugin>net.bytebuddy.build.AccessControllerPlugin</plugin>
<arguments>
<argument>
Expand All @@ -172,13 +172,13 @@
<transformation>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.12.18</version>
<version>1.12.19</version>
<plugin>net.bytebuddy.build.DispatcherAnnotationPlugin</plugin>
</transformation>
<transformation>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.12.18</version>
<version>1.12.19</version>
<plugin>net.bytebuddy.build.RepeatedAnnotationPlugin</plugin>
</transformation>
</transformations>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,17 @@ public TypeDescription.Generic findVariable(String symbol) {
public TypeDescription.Generic findExpectedVariable(String symbol) {
TypeDescription.Generic variable = findVariable(symbol);
if (variable == null) {
throw new IllegalArgumentException("Cannot resolve " + symbol + " from " + this);
throw new IllegalArgumentException("Cannot resolve " + symbol + " from " + toSafeString());
}
return variable;
}

/**
* Returns a {@link Object#toString()} representation that does not attempt to resolve any
* type variables to avoid stack overflow exceptions.
*
* @return A safe string representation.
*/
protected abstract String toSafeString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,20 @@ public String toString() {
}
return stringBuilder.toString();
}

@Override
protected String toSafeString() {
StringBuilder stringBuilder = new StringBuilder();
int modifiers = getModifiers() & SOURCE_MODIFIERS;
if (modifiers != EMPTY_MASK) {
stringBuilder.append(Modifier.toString(modifiers)).append(' ');
}
if (isMethod()) {
stringBuilder.append(getReturnType().asErasure().getActualName()).append(' ');
stringBuilder.append(getDeclaringType().asErasure().getActualName()).append('.');
}
return stringBuilder.append(getName()).append("(?)").toString();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8336,6 +8336,11 @@ public String toString() {
return (isPrimitive() ? "" : (isInterface() ? "interface" : "class") + " ") + getName();
}

@Override
protected String toSafeString() {
return toString();
}

/**
* An adapter implementation of a {@link TypeDescription} that
* describes any type that is not an array or a primitive type.
Expand Down
6 changes: 6 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Byte Buddy release notes
------------------------

### 17. November 2022: version 1.12.19

- Avoid possible lock through circular class loading of `TypeDescription` subtypes.
- Avoid access error when using unsafe API on Java 17 with an active security manager.
- Close URL class loader used in Gradle plugin.

### 11. October 2022: version 1.12.18

- Allow writing to field from enter `Advice` in constructor, as byte code allows it.
Expand Down

0 comments on commit c912dcf

Please sign in to comment.