codeconsole commented on PR #3097:
URL: https://github.com/apache/groovy/pull/3097#issuecomment-6700491444

   @blackdrag This is now path 2, as proposed. The meta-class route is gone, 
`invokeNew` included, and the writers emit what master emits.
   
   - **Compile time and run time may see different classes.** Nothing is 
selected at run time now. Each in-memory compilation is defined by a new 
`InnerLoader` that defines only that compilation's classes, so a class of the 
same package name outside the compilation is in another run-time package, 
whatever class the name resolves to at run time. That access is reported when 
the class is generated.
   - **The meta-class can influence the call.** Statically compiled code no 
longer goes through it for these members. The error suggests `@CompileDynamic` 
for anyone who wants that.
   - **Run time may still fail.** With the option on, it no longer gets to run 
time. With it off, it fails with `IllegalAccessError` as on master.
   
   The option is `CompilerConfiguration.RUNTIME_PACKAGE_CHECK`, off by default, 
with the same bytecode as before, and no effect on class files. `GroovyShell` 
turns it on for the class loader it creates, unless the configuration sets it. 
It does that on the loader rather than in the configuration, so 
`CompilerConfiguration.DEFAULT` stays read-only and a configuration changed 
after the shell is created still applies.
   
   Your comment on `isFieldDirectlyAccessible` no longer applies: that method 
and `isMemberDirectlyAccessible` are back to what master has. The check is in a 
new `RuntimePackageCheck`, and its only conditions are the package name, 
`isInSameRuntimePackage`, and the protected subclass rule of JVMS 5.4.4 and 
4.10.1.8.
   
   #3098 is the same check for a package-private class, on the instructions 
that name the class. The rest moved as proposed:
   - protected members of another package: #3251
   - `super$` for a package-private method of another run-time package: #3099
   - dynamic `super.f`, `super.@f` and `this.@f` of such a field: #3252
   - the invokedynamic `GroovyBugError` for a constructor the JVM refuses: #3253
   
   Your objection also applies to something already on master: since #3022 
(GROOVY-12488), a constructor reference to such a constructor is selected at 
run time. I left that as it is, so `A::new` works and is not reported, because 
reporting it would break code that works today. Say if you want it under this 
option too.
   


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