Udo Borkowski Udo Borkowski - 1 year ago 111
Java Question

How to define Eclipse external null annotations for parameters in JRE methods

I am trying to annotate the JRE method

<T> T[] toArray(T[] a)
using Eclipse's external null annotations. The expected effect should be equivalent to this:

public interface Set<E> extends Collection<E> {
<T> T @NonNull[] toArray(T @NonNull[] a);

When using Eclipse's Annotate command I can annotate the return type of the method properly (after I selected the
and position the cursor before the
). However trying to do the same with the parameter fails. Pressing Cmd-1 simply beeps, as does selecting "Annotate" when calling the command from the context menu.

I finally ended up editing the corresponding
file manually to defined the required annotation, taking care of the proper eea file layout. I.e. I changed the annotatedSignature in:

class java/util/Set



This works fine and the annotation is correctly processed by the compiler.

As I can annotate the return type but not a parameter type I am wondering what I am doing wrong. Or is this a limitation of the current Eclipse version?

I am using Eclipse Mars Release (4.5.0, Build id: 20150621-1200)
and jdk1.8.0_60.

Answer Source

This is a bug indeed, I just filed https://bugs.eclipse.org/477461 to track this.

This was bug 464081 which got fixed for 4.6 M1 (i.e., is available in current builds towards Eclipse Neon) and is currently proposed for 4.5.2 (Mars.2)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download