-
Type:
Bug
-
Resolution: Duplicate
-
Priority:
P3
-
None
-
Affects Version/s: 8
-
Component/s: core-libs
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
macOs (aarch64), Linux (x86_64) and certainly Windows
A DESCRIPTION OF THE PROBLEM :
Oracle Java 1.8u471, and not OpenJDK 1.8 u471, suffer from a bug when reading parameters via reflection (`Exceutable::getParameters`).
There was an existing bug https://bugs.openjdk.org/browse/JDK-8058322, and an existing report for the same problem https://bugs.openjdk.org/browse/JDK-8341145 whioch is due to better adherence to JVMS in Java 21 https://bugs.openjdk.org/browse/JDK-8292275.
JDK-8058322 received a backport fix https://git.openjdk.org/jdk8u/pull/63. So this is indeed fixed in OpenJDK distributions of 1.8, however Oracle Java do not seem to have received this patch.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Basically, I created a reproducer project here : https://github.com/bric3/malformed-parameters-oracle-8
But basically take this code, compile it with JDK 21 compiler with `--release 8`, then run it on Oracle Java 1.8, and to compare on another openjdk distribution.
---------- BEGIN SOURCE ----------
public class Reproducer {
/** Public to ease code-generation. Not meant to be used out of the parent class. */
public interface MyGenericConsumer<T> {
void accept(T arg);
}
/** Public to ease code-generation. Not meant to be used out of the parent class. */
public static class DefaultRunnableConsumer implements MyGenericConsumer<Runnable> {
@Override
public void accept(final Runnable runnable) {
runnable.run();
}
}
public static void main(String[] args) throws NoSuchMethodException {
// Fails on synthetic method on Oracle 8 u471
Reproducer.DefaultRunnableConsumer.class.getDeclaredMethod("accept", Object.class).getParameters();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
There are several : using a previous JDK to compile, using `-parameters` on the compiler but this adds too much additional and useless data for some constrained environments.
FREQUENCY :
ALWAYS
macOs (aarch64), Linux (x86_64) and certainly Windows
A DESCRIPTION OF THE PROBLEM :
Oracle Java 1.8u471, and not OpenJDK 1.8 u471, suffer from a bug when reading parameters via reflection (`Exceutable::getParameters`).
There was an existing bug https://bugs.openjdk.org/browse/JDK-8058322, and an existing report for the same problem https://bugs.openjdk.org/browse/JDK-8341145 whioch is due to better adherence to JVMS in Java 21 https://bugs.openjdk.org/browse/JDK-8292275.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Basically, I created a reproducer project here : https://github.com/bric3/malformed-parameters-oracle-8
But basically take this code, compile it with JDK 21 compiler with `--release 8`, then run it on Oracle Java 1.8, and to compare on another openjdk distribution.
---------- BEGIN SOURCE ----------
public class Reproducer {
/** Public to ease code-generation. Not meant to be used out of the parent class. */
public interface MyGenericConsumer<T> {
void accept(T arg);
}
/** Public to ease code-generation. Not meant to be used out of the parent class. */
public static class DefaultRunnableConsumer implements MyGenericConsumer<Runnable> {
@Override
public void accept(final Runnable runnable) {
runnable.run();
}
}
public static void main(String[] args) throws NoSuchMethodException {
// Fails on synthetic method on Oracle 8 u471
Reproducer.DefaultRunnableConsumer.class.getDeclaredMethod("accept", Object.class).getParameters();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
There are several : using a previous JDK to compile, using `-parameters` on the compiler but this adds too much additional and useless data for some constrained environments.
FREQUENCY :
ALWAYS
- duplicates
-
JDK-8058322 Zero name_index item of MethodParameters attribute cause MalformedParameterException.
-
- Resolved
-
- relates to
-
JDK-8058322 Zero name_index item of MethodParameters attribute cause MalformedParameterException.
-
- Resolved
-
-
JDK-8292275 javac does not emit SYNTHETIC and MANDATED flags for parameters by default
-
- Resolved
-
-
JDK-8341145 MalformedParametersException when using reflection on an inner class constructor
-
- Closed
-