groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Angela Vibar Guardian (JIRA)" <>
Subject [jira] [Created] (GROOVY-8286) Groovy does not respect package-private modifier of Java class
Date Fri, 11 Aug 2017 07:47:00 GMT
Angela Vibar Guardian created GROOVY-8286:

             Summary: Groovy does not respect package-private modifier of Java class
                 Key: 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

package org.example.people;

public class Person {
    private String name;

    void setName(String name) { = name;

    public String getName() {

And I have a Groovy class {{Main}} in package {{org.example}}:

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.

Is this standard? Using {{\@CompileStatic}}, though, throws an {{IllegalAccessException}}.

This message was sent by Atlassian JIRA

View raw message