[ 
https://issues.apache.org/jira/browse/GROOVY-8286?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16123756#comment-16123756
 ] 

Jochen Theodorou commented on GROOVY-8286:
------------------------------------------

this is standard for the past years yes. I am considering changing this because 
of JDK9 though

> Groovy does not respect package-private modifier of Java class
> --------------------------------------------------------------
>
>                 Key: GROOVY-8286
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8286
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.8
>            Reporter: Angela Vibar Guardian
>
> Hi. I'm using Java (1.8) with Groovy (2.4.8) via GMavenPlus (although with 
> the project I'm working on, we actually also programmatically compile Groovy 
> code and add it to the class loader to mix them up). It seems however, in 
> Groovy scripts/classes, package-private methods defined in a Java class can 
> be called.
> For example, I have a Java class {{Person}} in package 
> {{org.example.people}}, defined like so:
> {code:java}
> package org.example.people;
> public class Person {
>     private String name;
>     void setName(String name) {
>         this.name = name;
>     }
>     public String getName() {
>         return this.name;
>     }
> }
> {code}
> And I have a Groovy class {{Main}} in package {{org.example}}:
> {code:java}
> package org.example
> import groovy.transform.CompileStatic
> import org.example.people.Person
> class Main {
>     static void main(String[] args) {
>         Person person = new Person()
>         person.setName('Bob') // Shouldn't be call-able since they belong to 
> different packages.
>         println person.getName() // Prints 'Bob' to the console.
>     }
> }
> {code}
> Is this standard? Using {{\@CompileStatic}}, though, throws an 
> {{IllegalAccessException}}.
>  



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to