Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Trying out External Annotations for null analysis, but Annotate does nothing
Trying out External Annotations for null analysis, but Annotate does nothing [message #1735525] Mon, 20 June 2016 15:21 Go to next message
Michael Vorburger is currently offline Michael VorburgerFriend
Messages: 103
Registered: July 2009
Senior Member
Hello,

I'd like to try out the External Annotations for null analysis, but the right-click Annotate context action does nothing for me.

Details: See my micro example project on https://github.com/vorburger/eclipse-null-eea-augments. So I have the "hello" and the "slf4j-api--eea-LATEST" projects open in Eclipse. The "hello" project is, for now, intentionally with hard-coded absolute path for its 2 JAR dependencies (annotations and slf4j); and the slfj4 JAR has a source JAR (hard-coded; I want to think about Maven integration as a next step), annotation based null analysis is enabled for that hello project, and an external annotation location is be defined for the slf4j library and that location is another project within the workspace ("slf4j-api--eea-LATEST", but it's completely empty).

As described e.g. on http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftask-using_external_null_annotations.htm (Mars instead of Neon, but I don't think this changed?), I now F3 Ctrl-Click on the LoggerFactory.getLogger in /hello/src/main/java/ch/vorburger/nulls/examples/hello/Hello.java, which has the "Null type safety (type annotations): The expression of type 'Logger' needs unchecked conversion to conform to '@NonNull Logger'", good, thanks, to jump into my e.g. /home/vorburger/.m2/repository/org/slf4j/slf4j-api/1.7.21/slf4j-api-1.7.21-sources.jar line 382, where I mark the Class<?> clazz argument of the public static Logger getLogger() method - and right-click and choose Annotate. But nothing happens! I expected it to prompt me with Q how to annotate as per the doc, and for it to then create an eea file in that "slf4j-api--eea-LATEST" project.

There is nothing in the Error Log.

I'm on a Neon 4.6.0RC3.

Thanks for guidance!
Re: Trying out External Annotations for null analysis, but Annotate does nothing [message #1736102 is a reply to message #1735525] Sun, 26 June 2016 04:25 Go to previous messageGo to next message
Michael Vorburger is currently offline Michael VorburgerFriend
Messages: 103
Registered: July 2009
Senior Member
Hello. Do external null annotations work for any of you? Did you get right-click "Annotate" to work?
Re: Trying out External Annotations for null analysis, but Annotate does nothing [message #1736103 is a reply to message #1736102] Sun, 26 June 2016 06:24 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi<br>
<br>
Yes. They work, although the 'infos' for @Nullable T returns for
@NonNull T have regressed.<br>
<br>
Some of the JDT annotation processes are quite slow and some
@NonNull changes seem to need at least an editor save to activate
the change.<br>
<br>
Before dismissing something in Eclipse as totally non-functional,
it is often prudent to restart, clean, rebuild.<br>
<br>
There was (seemingly still is) a confusingly dead ability to
specify annotations for each JAR. They should be specified twice,
once for the JRE and once for Plug-in Dependencies.<br>
<br>
    Regards<br>
<br>
        Ed Willink<br>
<br>
<br>
<img src="https://www.eclipse.org/forums/index.php?t=getfile&amp;id=26277" alt=""><br>
<br>
<br>
On 26/06/2016 05:25, Michael Vorburger wrote:<br>
</div>
<blockquote cite="mid:nknlf5$tio$1@xxxxxxxxe.org" type="cite">Hello.
Do external null annotations work for any of you? Did you get
right-click "Annotate" to work?
<br>
</blockquote>
<p><br>
</p>
</body>
</html>
Re: Trying out External Annotations for null analysis, but Annotate does nothing [message #1736630 is a reply to message #1736103] Thu, 30 June 2016 16:34 Go to previous messageGo to next message
Michael Vorburger is currently offline Michael VorburgerFriend
Messages: 103
Registered: July 2009
Senior Member
Given the silence here (Stephane?) I've now actually set up a JDT Dev Env WS (not too hard, thanks Oomph!) to attempt debugging why "Annotate" does nothing (for me) :

Starting with a BP in AnnotateClassFileAction, I can see that in org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionAssistant.collectQuickFixableAnnotations(ITextEditor, int, boolean, ArrayList<Annotation>) the IAnnotationModel model == null, bad start?

I'm interested in contributing to https://bugs.eclipse.org/bugs/show_bug.cgi?id=449653, but without being able to get even basic Annotate to work, I'm not going to go very far...
Re: Trying out External Annotations for null analysis, but Annotate does nothing [message #1736634 is a reply to message #1736630] Thu, 30 June 2016 16:50 Go to previous messageGo to next message
Michael Vorburger is currently offline Michael VorburgerFriend
Messages: 103
Registered: July 2009
Senior Member
Oh!! stepping through org.eclipse.jdt.internal.corext.fix.ExternalNullAnnotationChangeProposals.collectExternalAnnotationProposals(ICompilationUnit, ASTNode, int, ArrayList<IJavaCompletionProposal>) I finally just figured out that Annotate works if your cursor is on the return type instead of the method name! Which makes perfect sense of course. Once you know it. Duh. Sorry for the noise!

Case closed. More later I hope.
Re: Trying out External Annotations for null analysis, but Annotate does nothing [message #1736656 is a reply to message #1736634] Thu, 30 June 2016 22:27 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Sorry for my silence, I just didn't have any quick ideas how to proceed.
Glad you figured it out.
Since not every user will dive into the debugger, let me know if the documentation could be improved.

Stephan
Re: Trying out External Annotations for null analysis, but Annotate does nothing [message #1736692 is a reply to message #1736656] Fri, 01 July 2016 08:06 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

It is not really a documentation problem.

IMHO a tool is always at fault if it offers a facility and then silently
does nothing. In this case there is a missing diagnostic popup informing
about the inappropriate activation context.

IMHO a tool is also at fault if it hides a facility and fails to explain
the hiding. So if a menu option is greyed out, we really should have a
hover text to explain why. (And disabled menu options should be greyed
out rather than removed.)

Regards

Ed Willink



On 30/06/2016 23:27, Stephan Herrmann wrote:
> Sorry for my silence, I just didn't have any quick ideas how to proceed.
> Glad you figured it out.
> Since not every user will dive into the debugger, let me know if the
> http://help.eclipse.org/topic/org.eclipse.jdt.doc.user/tasks/task-using_external_null_annotations.htm&anchor=create
> could be improved.
>
> Stephan
>
Re: Trying out External Annotations for null analysis, but Annotate does nothing [message #1736714 is a reply to message #1736692] Fri, 01 July 2016 09:56 Go to previous message
Michael Vorburger is currently offline Michael VorburgerFriend
Messages: 103
Registered: July 2009
Senior Member
> let me know if the (doc) could be improved.

Upon re-reading it, "select the type (method parameter or method return type)" is actually fairly clear... Wink

> missing diagnostic popup informing about the inappropriate activation context
> a menu option is greyed out, we really should have a hover text to explain why

In an ideal world, that would be cool. Realizing that this is a volunteer driven effort, I wouldn't say it's a high priority though (compared to spending time on ironing out any remaining bugs in null analysis, if there are any).

Most importantly is probably finish up the tooling story, e.g. incl. (a) establishing a repository with null annotations for commonly used FLOSS libs, with an open culture inviting many to contribute; and (b) auto. loading and associating *.eea, through Maven (and, later, Gradle). IMHO these two points are maybe what's missing most now. I'll see if I can perhaps contribute to both of those in the coming weeks & months; and will let you know when I have something to show, or discuss.
Previous Topic:Run configuration file exists in workspace directory but not visible in UI
Next Topic:Java Editor extremely slow on larger (10000 lines) files
Goto Forum:
  


Current Time: Sat Apr 20 00:28:41 GMT 2024

Powered by FUDForum. Page generated in 0.06325 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top