Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.0.9
-
None
Description
When calling a groovy class from java that takes a Map in the constructor, the generated stubs have what looks to be a second constructor that takes a null for the parameter, that casted to a raw Map. Since this happens in generated code not under my control, this prevents enabling -Werror across the project. Providing type arguments for the map or leaving the cast off would fix the warning, but I also wonder if suppressing the constructor is possible.
Below are the commands I ran, along with the contents of the java and groovy files:
groovyc -j -FWerror -FXlint:unchecked Test.java Base.groovy org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Compile error during compilation with javac. /var/folders/mm/8s324dkd6sb1ktx0g48pbvhc0000gq/T/groovy-generated--java-source3303303787390544788/Base.java:13: warning: [unchecked] unchecked method invocation: constructor <init> in class Parent is applied to given types super ((java.util.Map)null); ^ required: Map<String,String> found: Map /var/folders/mm/8s324dkd6sb1ktx0g48pbvhc0000gq/T/groovy-generated--java-source3303303787390544788/Base.java:13: warning: [unchecked] unchecked conversion super ((java.util.Map)null); ^ required: Map<String,String> found: Map error: warnings found and -Werror specified 1 error 2 warnings
cat -p Base.groovy class Parent { Parent(Map<String, String> map) { } } class Base extends Parent { Base(Map<String, String> map) { super(map); } } cat -p Test.java import java.util.Map; class Test { Base b = new Base(Map.of()); }