question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Illegal parameter name of java.lang.String <set-?>

See original GitHub issue

I 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.

sample.zip

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
raphwcommented, Oct 18, 2022

Should be released as of this week.

2reactions
raphwcommented, Oct 6, 2022

Waiting for feedback on one other issue, then its gonna be a new 1.12.x

Read more comments on GitHub >

github_iconTop Results From Across the Web

You have attempted to set a parameter value using a name of ...
java.lang.IllegalArgumentException: You have attempted to set a parameter value using a name of string that does not exist in the query string ......
Read more >
Top 6 Ways To Fix Illegal Start Of Expression Error In Java
Using the public access modifier with the “mammals” class will generate an illegal start of expression java error. 1. public class Animals {...
Read more >
ParameterPage (PegaRULES Java Engine v7.4.0 - PUBLIC)
The ParameterPage class allows a collection of String -valued, named parameters to be shared easily and automatically during processing. Parameter names are ...
Read more >
Issue with Parameters that are from a List
I have set up a parameter as follows. Parameter Name ... JRRuntimeException: Invalid type + java.lang.String for parameter A used in an IN ......
Read more >
Solving java.lang.IllegalArgumentException
This exception is thrown in order to indicate that a method has been passed an illegal or inappropriate argument. For example, if a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found