Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paranamer 2.8 on Java 8 causes "Parameter names not found" error #1133

Open
tribbloid opened this issue Sep 29, 2022 · 2 comments
Open

Paranamer 2.8 on Java 8 causes "Parameter names not found" error #1133

tribbloid opened this issue Sep 29, 2022 · 2 comments

Comments

@tribbloid
Copy link

Paranamer hasn't been updated for a very long time and is now causing all kinds of trouble in later Java versions, its time to finally drop it and uses the much more stable Java reflection for the same purpose.

When running the following code:

  case class TimeWrapper(time: Date)

    val clazz = classOf[TimeWrapper]
    val tors = clazz.getConstructors
    val ctor = tors.head
    val exe = new Executable(ctor)

    val names = ParanamerReader.lookupParameterNames(exe)

    require(names.size == 1)

Paranamer throw the following error:

Parameter names not found for <init>
com.thoughtworks.paranamer.ParameterNamesNotFoundException: Parameter names not found for <init>
	at com.thoughtworks.paranamer.BytecodeReadingParanamer$TypeCollector.getParameterNamesForMethod(BytecodeReadingParanamer.java:241)
	at com.thoughtworks.paranamer.BytecodeReadingParanamer$TypeCollector.access$300(BytecodeReadingParanamer.java:144)
	at com.thoughtworks.paranamer.BytecodeReadingParanamer.lookupParameterNames(BytecodeReadingParanamer.java:104)
	at com.thoughtworks.paranamer.CachingParanamer.lookupParameterNames(CachingParanamer.java:90)
	at com.thoughtworks.paranamer.CachingParanamer.lookupParameterNames(CachingParanamer.java:83)
	at org.json4s.reflect.package$ParanamerReader$.lookupParameterNames(package.scala:92)
	at org.apache.spark.ml.dsl.utils.messaging.MessageReaderSuite.$anonfun$new$3(MessageReaderSuite.scala:34)
...

Test was conducted on Java 8, it is unknown whether it can be triggered reliably

json4s version

4.0.4

scala version

2.12.16

jdk version

OpenJDK 8

@magnolia-k
Copy link
Contributor

d0781fe

@tribbloid
Copy link
Author

Thanks a lot! Turns out that the old paranamer depends on metadata from the "-g:vars" compiler argument to work, but this is a huge reduction of vulnerability!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants