Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Package visible java constructor or method not accessible #520

Open
yloiseau opened this issue Mar 15, 2018 · 0 comments
Open

Package visible java constructor or method not accessible #520

yloiseau opened this issue Mar 15, 2018 · 0 comments
Labels

Comments

@yloiseau
Copy link
Contributor

yloiseau commented Mar 15, 2018

Given the Java class

package net.yloiseau.tools;

public class A {
  private final int answer;

  A(int v) { this.answer = v; }

  public static A of(int v) { return new A(v); }

  public int answer() { return this.answer; }

  String meth() { return "A.meth"; }

  static String fun() { return "A.fun"; }
}

and the golo module

module net.yloiseau.tools.Main

function createA = |v| -> net.yloiseau.tools.A(v)
function callFun = -> net.yloiseau.tools.A.fun()
function callMeth = -> net.yloiseau.tools.A.of(42): meth()

All functions should be OK, since the module and the java class are in the same package. Indeed, in

module Main

import net.yloiseau.tools

function main = |args| {
  println(Main.callFun())
  println(Main.createA(42): answer())
  println(Main.callMeth())
}

the first print that call a static function works just fine. However, both the function calling the constructor createA or the method callMeth fail with a NoSuchMethodError. Making the A constructor or meth method public works as expected.

Since the generated class representing the module, and thus the createA and callMeth methods are in the same package as the A class, the method should be found.

Sample files here: https://github.com/yloiseau/golo-tests/tree/master/BUGS/520-package-visibility

@yloiseau yloiseau added the bug label Mar 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant