Illegal parameter name of java.lang.String <set-?>
See original GitHub issueI am using the byte-buddy maven plugin on a Kotlin project. I need to retain the parameters for another library. Currently the byte-buddy plugin now fails on transforming the class.
This works if i do not retain parameters, so it looks like Kotlin generates some parameter names for the setter on properties that byte-buddy is unable to handle.
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>sample</groupId>
<artifactId>sample</artifactId>
<version>1.0</version>
<properties>
<kotlin.version>1.3.72</kotlin.version>
<bytebuddy.version>1.10.9</bytebuddy.version>
</properties>
<dependencies>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-dep</artifactId>
<version>${bytebuddy.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>1.8</jvmTarget>
<args>
<arg>-java-parameters</arg>
</args>
</configuration>
</plugin>
<plugin>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-maven-plugin</artifactId>
<version>${bytebuddy.version}</version>
<executions>
<execution>
<goals>
<goal>transform</goal>
</goals>
</execution>
</executions>
<configuration>
<transformations>
<transformation>
<plugin>sample.MyPlugin</plugin>
</transformation>
</transformations>
</configuration>
</plugin>
</plugins>
</build>
</project>
This is the line that will retain parameters. Project builds successfully without this line. <arg>-java-parameters</arg>
Class1.kt (this one fails)
class Class1 {
var name: String? = null
}
Class2.kt (this one succeeds)
class Class2 {
var name: String? = null
get() = field
set(value) { field = value }
}
Class2 causes no errors, i believe this is because i have given the setter a parameter name. The plugin itself does nothing.
override fun apply(builder: DynamicType.Builder<*>, typeDescription: TypeDescription, classFileLocator: ClassFileLocator
): DynamicType.Builder<*> {
return builder
}
The error output is as follows:
mvn install … …
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.192 s
[INFO] Finished at: 2020-04-22T19:31:34+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal net.bytebuddy:byte-buddy-maven-plugin:1.10.9:transform (default) on project sample: Failed to transform class files in C:\Users\MyUser\source\repos\untitled4\target\classes: Illegal parameter name of java.lang.String <set-?> for public final void sample.Class1.setName(java.lang.String) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
I have attached a zip file with this sample. Please let me know if i can be of further assistance. This is currently a blocker on our project.
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (7 by maintainers)
Should be released as of this week.
Waiting for feedback on one other issue, then its gonna be a new 1.12.x