Skip to content

java_signature throws NPE when using positional annotation arguments #7117

@byteit101

Description

@byteit101

Environment Information
JRuby 9.3 branch

Expected Behavior

class AnnotatedClass
  java_signature '@a.loaded.annotation.Class("phantom") void test(boolean)'
  def test(p)
  end
end
# no output, but AnnotationClass is now configured appropriately

Actual Behavior

Traceback (most recent call last):
       16: from org.jruby.RubyEnumerable.inject(org/jruby/RubyEnumerable.java:1024)
       15: from org.jruby.RubyEnumerable.injectCommon(org/jruby/RubyEnumerable.java:1005)
       14: from org.jruby.RubyEnumerable.callEach(org/jruby/RubyEnumerable.java:87)
       13: from org.jruby.javasupport.ext.JavaUtil$Collection$INVOKER$s$0$0$each.call(org/jruby/javasupport/ext/JavaUtil$Collection$INVOKER$s$0$0$each.gen)
       12: from org.jruby.javasupport.ext.JavaUtil$Collection.each(org/jruby/javasupport/ext/JavaUtil.java:137)
       11: from org.jruby.javasupport.ext.JavaLang$Iterable.each(org/jruby/javasupport/ext/JavaLang.java:110)
       10: from org.jruby.RubyEnumerable.lambda$injectCommon$3(org/jruby/RubyEnumerable.java:1009)
        9: from RUBY.annotation(ruby/stdlib/jruby/compiler/java_signature.rb:135)
        8: from org.jruby.javasupport.JavaMethod.invokeDirect(org/jruby/javasupport/JavaMethod.java:294)
        7: from org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(org/jruby/javasupport/JavaMethod.java:427)
        6: from java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:566)
        5: from jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(jdk/internal/reflect/DelegatingMethodAccessorImpl.java:43)
        4: from jdk.internal.reflect.NativeMethodAccessorImpl.invoke(jdk/internal/reflect/NativeMethodAccessorImpl.java:62)
        3: from jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        2: from java.lang.Class.getMethod(java/lang/Class.java:2101)
        1: from java.util.Objects.requireNonNull(java/util/Objects.java:221)
Java::JavaLang::NullPointerException ()

Workaround

add the annotation name:

class AnnotatedClass
  java_signature '@a.loaded.annotation.Class(value="phantom") void test(boolean)'
  def test(p)
  end
end

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions