Thibault Kruse
2015-03-14 13:12:03 UTC
Hi,
regarding more safety using @CompileStatic by default, I tried a few things.
It seems when using @CompileStatic, i get "Access to Foo.xyz is
forbidden" if Foo.yz is a package-protected field of a *Java* class
and the groovy class is within the *same* package.
However accessing package private *methods* works.
Even more confusing, the same goes for both if accessing
package-private members from other packages (Compiler will allow
accessing package-protected methods).
At runtime, when invoking a package-protected method from a different
package, I get "file:///home/kruset/work/java/packageAccess/build/reports/tests/index.html"
Is that all intentional?
Also, somewhat annoying, the gradle groovy plugin does not recompile
the Groovy classes when Java classes change (within src/main/java).
That is:
public class Library {
boolean someLibraryMethod() {
return true;
}
int foo = 3;
}
import groovy.transform.CompileStatic
@CompileStatic
public class GLibrary {
public boolean someLibraryMethod() {
Library lib = new Library()
println(lib.foo) // Access to Library#foo is forbidden
println(lib.someLibraryMethod()) // works
return true
}
}
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
regarding more safety using @CompileStatic by default, I tried a few things.
It seems when using @CompileStatic, i get "Access to Foo.xyz is
forbidden" if Foo.yz is a package-protected field of a *Java* class
and the groovy class is within the *same* package.
However accessing package private *methods* works.
Even more confusing, the same goes for both if accessing
package-private members from other packages (Compiler will allow
accessing package-protected methods).
At runtime, when invoking a package-protected method from a different
package, I get "file:///home/kruset/work/java/packageAccess/build/reports/tests/index.html"
Is that all intentional?
Also, somewhat annoying, the gradle groovy plugin does not recompile
the Groovy classes when Java classes change (within src/main/java).
That is:
public class Library {
boolean someLibraryMethod() {
return true;
}
int foo = 3;
}
import groovy.transform.CompileStatic
@CompileStatic
public class GLibrary {
public boolean someLibraryMethod() {
Library lib = new Library()
println(lib.foo) // Access to Library#foo is forbidden
println(lib.someLibraryMethod()) // works
return true
}
}
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email