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

Master fix #42

Merged
merged 7 commits into from
Jan 21, 2021
Merged

Master fix #42

merged 7 commits into from
Jan 21, 2021

Conversation

ryanemerson
Copy link
Contributor

@wburns This fixes a compilation issue with the latest Infinispan master, however I'm now getting the following:

[INFO] --- quarkus-maven-plugin:1.8.3.Final:native-image (default) @ infinispan-quarkus-server-runner ---
[INFO] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Building native image source jar: /home/remerson/workspace/RedHat/infinispan/infinispan-quarkus/server-runner/target/infinispan-quarkus-server-runner-12.0.0-SNAPSHOT-native-image-source-jar/infinispan-quarkus-server-runner-12.0.0-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Building native image from /home/remerson/workspace/RedHat/infinispan/infinispan-quarkus/server-runner/target/infinispan-quarkus-server-runner-12.0.0-SNAPSHOT-native-image-source-jar/infinispan-quarkus-server-runner-12.0.0-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on GraalVM Version 20.2.0 (Java Version 11.0.8)
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] /home/remerson/Programs/graalvm-ce-java11-20.2.0/bin/native-image -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=1 -J-Dsubstratevm.replacement.jdksslcontext=false -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Duser.language=en -J-Dfile.encoding=UTF-8 --allow-incomplete-classpath --initialize-at-build-time= -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy\$BySpaceAndTime -H:+JNI -jar infinispan-quarkus-server-runner-12.0.0-SNAPSHOT-runner.jar -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:-AddAllCharsets -H:EnableURLProtocols=http,https --enable-all-security-services -H:NativeLinkerOption=-no-pie --no-server -H:-UseServiceLoaderFeature -H:+StackTrace infinispan-quarkus-server-runner-12.0.0-SNAPSHOT-runner
[infinispan-quarkus-server-runner-12.0.0-SNAPSHOT-runner:189139]    classlist:  10,277.39 ms,  1.18 GB
[infinispan-quarkus-server-runner-12.0.0-SNAPSHOT-runner:189139]        (cap):     675.04 ms,  1.18 GB
[infinispan-quarkus-server-runner-12.0.0-SNAPSHOT-runner:189139]        setup:   2,355.35 ms,  1.18 GB
17:56:42,577 INFO  [org.jbo.threads] JBoss Threads version 3.1.1.Final
17:56:44,941 INFO  [org.wil.ope.SSL] WFOPENSSL0002 OpenSSL Version OpenSSL 1.1.1g FIPS  21 Apr 2020
17:56:44,943 INFO  [org.inf.SECURITY] ISPN000946: Using OpenSSL Provider
17:56:46,309 INFO  [org.hib.ann.com.Version] HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
17:56:50,966 INFO  [org.wil.security] ELY00001: WildFly Elytron version 1.12.1.Final
[infinispan-quarkus-server-runner-12.0.0-SNAPSHOT-runner:189139]     (clinit):   1,058.24 ms,  5.33 GB
[infinispan-quarkus-server-runner-12.0.0-SNAPSHOT-runner:189139]   (typeflow):  29,214.03 ms,  5.33 GB
[infinispan-quarkus-server-runner-12.0.0-SNAPSHOT-runner:189139]    (objects):  26,919.51 ms,  5.33 GB
[infinispan-quarkus-server-runner-12.0.0-SNAPSHOT-runner:189139]   (features):   1,666.48 ms,  5.33 GB
[infinispan-quarkus-server-runner-12.0.0-SNAPSHOT-runner:189139]     analysis:  62,562.08 ms,  5.33 GB
Error: Unsupported features in 3 methods
Detailed message:
Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Invoke with MethodHandle argument could not be reduced to at most a single call or single field access. The method handle must be a compile time constant, e.g., be loaded from a `static final` field. Method that contains the method handle invocation: java.lang.invoke.MethodHandle.invokeBasic(Object)
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The error is then reported at run time when the invoke is executed.
Trace: 
	at parsing java.lang.invoke.LambdaForm$MH/0x00000007c27e7440.invoke_MT(LambdaForm$MH)
Call path from entry point to java.lang.invoke.LambdaForm$MH/89291973.invoke_MT(Object, Object, Object): 
	at java.lang.invoke.LambdaForm$MH/0x00000007c27e7440.invoke_MT(LambdaForm$MH)
	at org.wildfly.security.key.KeyUtil$KeyClonerCreator.lambda$produceOp$4(KeyUtil.java:368)
	at org.wildfly.security.key.KeyUtil$KeyClonerCreator$$Lambda$4000/0x00000007c1ee6c40.apply(Unknown Source)
	at sun.security.ec.XECParameters$1.get(XECParameters.java:183)
	at com.oracle.svm.core.jdk.SystemPropertiesSupport.initializeLazyValue(SystemPropertiesSupport.java:190)
	at com.oracle.svm.core.jdk.SystemPropertiesSupport.getProperty(SystemPropertiesSupport.java:143)
	at com.oracle.svm.core.jdk.Target_java_lang_System.getProperty(JavaLangSubstitutions.java:331)
	at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VARARGS:Ljava_lang_System_2_0002egetProperty_00028Ljava_lang_String_2_00029Ljava_lang_String_2(generated:0)
Error: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported type java.lang.invoke.MemberName is reachable: All methods from java.lang.invoke should have been replaced during image building.
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
Trace: 
	at parsing java.lang.invoke.MethodHandles$Lookup.findConstructor(MethodHandles.java:1264)
Call path from entry point to java.lang.invoke.MethodHandles$Lookup.findConstructor(Class, MethodType): 
	at java.lang.invoke.MethodHandles$Lookup.findConstructor(MethodHandles.java:1260)
	at org.wildfly.security.key.KeyUtil$KeyClonerCreator.lambda$checkForCopyCtor$3(KeyUtil.java:357)
	at org.wildfly.security.key.KeyUtil$KeyClonerCreator$$Lambda$4001/0x00000007c1ee6840.run(Unknown Source)
	at com.oracle.svm.core.jdk.Target_java_security_AccessController.doPrivileged(SecuritySubstitutions.java:83)
	at sun.security.pkcs11.SunPKCS11.initToken(SunPKCS11.java:1028)
	at sun.security.pkcs11.SunPKCS11$TokenPoller.run(SunPKCS11.java:852)
	at java.lang.Thread.run(Thread.java:834)
	at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:517)
	at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
	at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)
Error: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported type java.lang.invoke.MemberName is reachable: All methods from java.lang.invoke should have been replaced during image building.
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
Trace: 
	at parsing java.lang.invoke.MethodHandles$Lookup.findVirtual(MethodHandles.java:1194)
Call path from entry point to java.lang.invoke.MethodHandles$Lookup.findVirtual(Class, String, MethodType): 
	at java.lang.invoke.MethodHandles$Lookup.findVirtual(MethodHandles.java:1186)
	at org.wildfly.security.key.KeyUtil$KeyClonerCreator.lambda$checkForCloneMethod$2(KeyUtil.java:345)
	at org.wildfly.security.key.KeyUtil$KeyClonerCreator$$Lambda$3999/0x00000007c1ee7440.run(Unknown Source)
	at com.oracle.svm.core.jdk.Target_java_security_AccessController.doPrivileged(SecuritySubstitutions.java:83)
	at sun.security.pkcs11.SunPKCS11.initToken(SunPKCS11.java:1028)
	at sun.security.pkcs11.SunPKCS11$TokenPoller.run(SunPKCS11.java:852)
	at java.lang.Thread.run(Thread.java:834)
	at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:517)
	at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
	at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)

com.oracle.svm.core.util.UserError$UserException: Unsupported features in 3 methods
Detailed message:
Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Invoke with MethodHandle argument could not be reduced to at most a single call or single field access. The method handle must be a compile time constant, e.g., be loaded from a `static final` field. Method that contains the method handle invocation: java.lang.invoke.MethodHandle.invokeBasic(Object)
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The error is then reported at run time when the invoke is executed.
Trace: 
	at parsing java.lang.invoke.LambdaForm$MH/0x00000007c27e7440.invoke_MT(LambdaForm$MH)
Call path from entry point to java.lang.invoke.LambdaForm$MH/89291973.invoke_MT(Object, Object, Object): 
	at java.lang.invoke.LambdaForm$MH/0x00000007c27e7440.invoke_MT(LambdaForm$MH)
	at org.wildfly.security.key.KeyUtil$KeyClonerCreator.lambda$produceOp$4(KeyUtil.java:368)
	at org.wildfly.security.key.KeyUtil$KeyClonerCreator$$Lambda$4000/0x00000007c1ee6c40.apply(Unknown Source)
	at sun.security.ec.XECParameters$1.get(XECParameters.java:183)
	at com.oracle.svm.core.jdk.SystemPropertiesSupport.initializeLazyValue(SystemPropertiesSupport.java:190)
	at com.oracle.svm.core.jdk.SystemPropertiesSupport.getProperty(SystemPropertiesSupport.java:143)
	at com.oracle.svm.core.jdk.Target_java_lang_System.getProperty(JavaLangSubstitutions.java:331)
	at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VARARGS:Ljava_lang_System_2_0002egetProperty_00028Ljava_lang_String_2_00029Ljava_lang_String_2(generated:0)
Error: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported type java.lang.invoke.MemberName is reachable: All methods from java.lang.invoke should have been replaced during image building.
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
Trace: 
	at parsing java.lang.invoke.MethodHandles$Lookup.findConstructor(MethodHandles.java:1264)
Call path from entry point to java.lang.invoke.MethodHandles$Lookup.findConstructor(Class, MethodType): 
	at java.lang.invoke.MethodHandles$Lookup.findConstructor(MethodHandles.java:1260)
	at org.wildfly.security.key.KeyUtil$KeyClonerCreator.lambda$checkForCopyCtor$3(KeyUtil.java:357)
	at org.wildfly.security.key.KeyUtil$KeyClonerCreator$$Lambda$4001/0x00000007c1ee6840.run(Unknown Source)
	at com.oracle.svm.core.jdk.Target_java_security_AccessController.doPrivileged(SecuritySubstitutions.java:83)
	at sun.security.pkcs11.SunPKCS11.initToken(SunPKCS11.java:1028)
	at sun.security.pkcs11.SunPKCS11$TokenPoller.run(SunPKCS11.java:852)
	at java.lang.Thread.run(Thread.java:834)
	at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:517)
	at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
	at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)
Error: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported type java.lang.invoke.MemberName is reachable: All methods from java.lang.invoke should have been replaced during image building.
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
Trace: 
	at parsing java.lang.invoke.MethodHandles$Lookup.findVirtual(MethodHandles.java:1194)
Call path from entry point to java.lang.invoke.MethodHandles$Lookup.findVirtual(Class, String, MethodType): 
	at java.lang.invoke.MethodHandles$Lookup.findVirtual(MethodHandles.java:1186)
	at org.wildfly.security.key.KeyUtil$KeyClonerCreator.lambda$checkForCloneMethod$2(KeyUtil.java:345)
	at org.wildfly.security.key.KeyUtil$KeyClonerCreator$$Lambda$3999/0x00000007c1ee7440.run(Unknown Source)
	at com.oracle.svm.core.jdk.Target_java_security_AccessController.doPrivileged(SecuritySubstitutions.java:83)
	at sun.security.pkcs11.SunPKCS11.initToken(SunPKCS11.java:1028)
	at sun.security.pkcs11.SunPKCS11$TokenPoller.run(SunPKCS11.java:852)
	at java.lang.Thread.run(Thread.java:834)
	at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:517)
	at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
	at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)

	at com.oracle.svm.core.util.UserError.abort(UserError.java:79)
	at com.oracle.svm.hosted.FallbackFeature.reportAsFallback(FallbackFeature.java:217)
	at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:765)
	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:555)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:468)
	at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Unsupported features in 3 methods
Detailed message:
Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Invoke with MethodHandle argument could not be reduced to at most a single call or single field access. The method handle must be a compile time constant, e.g., be loaded from a `static final` field. Method that contains the method handle invocation: java.lang.invoke.MethodHandle.invokeBasic(Object)
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The error is then reported at run time when the invoke is executed.
Trace: 
	at parsing java.lang.invoke.LambdaForm$MH/0x00000007c27e7440.invoke_MT(LambdaForm$MH)
Call path from entry point to java.lang.invoke.LambdaForm$MH/89291973.invoke_MT(Object, Object, Object): 
	at java.lang.invoke.LambdaForm$MH/0x00000007c27e7440.invoke_MT(LambdaForm$MH)
	at org.wildfly.security.key.KeyUtil$KeyClonerCreator.lambda$produceOp$4(KeyUtil.java:368)
	at org.wildfly.security.key.KeyUtil$KeyClonerCreator$$Lambda$4000/0x00000007c1ee6c40.apply(Unknown Source)
	at sun.security.ec.XECParameters$1.get(XECParameters.java:183)
	at com.oracle.svm.core.jdk.SystemPropertiesSupport.initializeLazyValue(SystemPropertiesSupport.java:190)
	at com.oracle.svm.core.jdk.SystemPropertiesSupport.getProperty(SystemPropertiesSupport.java:143)
	at com.oracle.svm.core.jdk.Target_java_lang_System.getProperty(JavaLangSubstitutions.java:331)
	at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VARARGS:Ljava_lang_System_2_0002egetProperty_00028Ljava_lang_String_2_00029Ljava_lang_String_2(generated:0)
Error: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported type java.lang.invoke.MemberName is reachable: All methods from java.lang.invoke should have been replaced during image building.
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
Trace: 
	at parsing java.lang.invoke.MethodHandles$Lookup.findConstructor(MethodHandles.java:1264)
Call path from entry point to java.lang.invoke.MethodHandles$Lookup.findConstructor(Class, MethodType): 
	at java.lang.invoke.MethodHandles$Lookup.findConstructor(MethodHandles.java:1260)
	at org.wildfly.security.key.KeyUtil$KeyClonerCreator.lambda$checkForCopyCtor$3(KeyUtil.java:357)
	at org.wildfly.security.key.KeyUtil$KeyClonerCreator$$Lambda$4001/0x00000007c1ee6840.run(Unknown Source)
	at com.oracle.svm.core.jdk.Target_java_security_AccessController.doPrivileged(SecuritySubstitutions.java:83)
	at sun.security.pkcs11.SunPKCS11.initToken(SunPKCS11.java:1028)
	at sun.security.pkcs11.SunPKCS11$TokenPoller.run(SunPKCS11.java:852)
	at java.lang.Thread.run(Thread.java:834)
	at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:517)
	at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
	at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)
Error: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported type java.lang.invoke.MemberName is reachable: All methods from java.lang.invoke should have been replaced during image building.
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
Trace: 
	at parsing java.lang.invoke.MethodHandles$Lookup.findVirtual(MethodHandles.java:1194)
Call path from entry point to java.lang.invoke.MethodHandles$Lookup.findVirtual(Class, String, MethodType): 
	at java.lang.invoke.MethodHandles$Lookup.findVirtual(MethodHandles.java:1186)
	at org.wildfly.security.key.KeyUtil$KeyClonerCreator.lambda$checkForCloneMethod$2(KeyUtil.java:345)
	at org.wildfly.security.key.KeyUtil$KeyClonerCreator$$Lambda$3999/0x00000007c1ee7440.run(Unknown Source)
	at com.oracle.svm.core.jdk.Target_java_security_AccessController.doPrivileged(SecuritySubstitutions.java:83)
	at sun.security.pkcs11.SunPKCS11.initToken(SunPKCS11.java:1028)
	at sun.security.pkcs11.SunPKCS11$TokenPoller.run(SunPKCS11.java:852)
	at java.lang.Thread.run(Thread.java:834)
	at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:517)
	at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
	at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)

	at com.oracle.graal.pointsto.constraints.UnsupportedFeatures.report(UnsupportedFeatures.java:129)
	at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:762)
	... 8 more
Error: Image build request failed with exit status 1

@galderz
Copy link
Member

galderz commented Jan 4, 2021

Created #44 to track this.

@ryanemerson ryanemerson force-pushed the fix_master branch 3 times, most recently from 92a9cd1 to e37d5dc Compare January 19, 2021 14:44
private UnaryOperator<Key> checkForCloneMethod(final Class<?> declType, final Class<?> returnType)
{
System.out.printf("Call checkForCloneMethod(%s,%s)%n", declType, returnType);
final Method method = doPrivileged(new PrivilegedAction<Method>()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use a lambda?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain how this fixes it? I thought the issue was that that it checked all the various classes for clone method in the reflection list and found an invalid one even though this would never invoke it, is that not true? Or are we working around that by using reflection methods directly instead of MethodHandle which seem to be stricter? To me this seems like a very brittle "fix".

Can you elaborate? Thanks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use a lambda?

Didn't work with lambdas. I got some error when using lambda, so I decided to use anonymous inner class which works just as fine.

Can you explain how this fixes it? I thought the issue was that that it checked all the various classes for clone method in the reflection list and found an invalid one even though this would never invoke it, is that not true? Or are we working around that by using reflection methods directly instead of MethodHandle which seem to be stricter? To me this seems like a very brittle "fix".

We're just doing the same logic that Elytron does but instead of using MethodHandles, use reflection. The use of MethodHandles was flat out rejected. Reflection works, but this logic will only kick in with particular keys that fit the bill, e.g. https://github.com/galderz/mendrugo/blob/master/elytron-cloning/src/main/java/org/example/elytron/Main.java#L189 or https://github.com/galderz/mendrugo/blob/master/elytron-cloning/src/main/java/org/example/elytron/Main.java#L138. The logic that reflection or methodhandles use only kicks in very specific scenarios, e.g. destroy() needs to be overriden and other stuff that the Elytron code requires (can't remember now). Now, whether Infinispan is affected by this or not is unknown to me. It depends on the types of keys it uses which I've no idea of. If any of those would be used, you'd need to register them for reflection for things to work. What these changes do is allow all of this to work.

If you have more doubts, I'd suggest you check out the demo code in here, run it, play with it and see how it all fits together.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't doubts as much as I was curious why reflection works but MethodHandles do. And the fact that I would think Graal would eventually add the same checking for reflection that MethodHandles has. But that is why I was curious as to why it actually worked.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've not looked at the MethodHandles code, but reflection works but capturing each class/method/constructor to be accessed, generates a proxy for each and eventually proxy instances are substituted by JDK internal reflection FieldAccessor/ConstructorAccessor/MethodAccessor instances.

if (method == null)
return null;

return new UnaryOperator<Key>()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here re: lambda.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.

@Substitute
private UnaryOperator<Key> checkForCloneMethod(final Class<?> declType, final Class<?> returnType)
{
System.out.printf("Call checkForCloneMethod(%s,%s)%n", declType, returnType);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need the printf anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot. Removed and I have updated the class to use our style conventions.

@wburns wburns merged commit 947f5bc into infinispan:master Jan 21, 2021
@wburns
Copy link
Member

wburns commented Jan 21, 2021

Integrated into master, thanks @ryanemerson !

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

Successfully merging this pull request may close these issues.

None yet

3 participants