codeconsole opened a new pull request, #3253:
URL: https://github.com/apache/groovy/pull/3253

   A dynamic `new` of a constructor that the JVM refuses to the caller fails 
with an internal error under invokedynamic:
   
   ```groovy
   class C extends ObjectInputStream {
       static ObjectInputStream make() {
           new ObjectInputStream()   // BUG! UNCAUGHT EXCEPTION: member is 
protected: java.io.ObjectInputStream.<init>
       }
   }
   C.make()
   ```
   
   5.0.8 and 6.0.0 fail the same way. The constructor selector unreflected the 
selected constructor with the lookup of the calling class and turned an 
`IllegalAccessException` into `GroovyBugError`. As the property selectors do 
since GROOVY-12314, it now treats the refusal as an access-control outcome and 
leaves the call to the meta-class, which reports "could not access 
constructor", as the call does without invokedynamic. A constructor that 
reflection can reach, such as a protected constructor of a class of another 
package in the unnamed module, is still called.
   
   ## Compatibility
   
   The exception changes from `GroovyBugError` to `GroovyRuntimeException`, the 
same one as without invokedynamic.
   
   ## Tests
   
   `IndyRefusedConstructorTest.testProtectedConstructorOfEncapsulatedJdkClass` 
fails with invokedynamic without the change; it runs with and without 
invokedynamic, and is skipped where the JVM opens `java.base/java.io`. 
`testProtectedConstructorOfClassOfAnotherPackage` pins the constructor that is 
still called. 4,598 tests in `org.codehaus.groovy.vmplugin.v8`, 
`org.codehaus.groovy.classgen.asm.sc`, `groovy.lang` and `gls` pass. The 
Checkstyle and CodeNarc gates pass.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to