Trouble with Java package imports

David Ventimiglia <[email protected]> Sun, 18 Sep 2016 11:57:48 -0700
Newsgroups gmane.emacs.semantic
Message-ID <CALaE=t-grOnQkueJ2Ua6gyYTHCQEKdX2oSnjuNgJNhcaDxiCEA@mail.gmail.com>
--===============3599484180320812026==
Content-Type: multipart/alternative; boundary=001a113cc00ac3705e053cccc670

--001a113cc00ac3705e053cccc670
Content-Type: text/plain; charset=UTF-8

Hi!

I'm having trouble with the Semantic Analyzer and "package imports" for
Java programs.  I've an example Java program that looks like this:

import java.util.*;
> import java.util.HashMap;
> public class HelloWorld2 {
>     public static void main (String[] args) {
> System.out.println("Hello, World!");
> Map m = new HashMap();
> m.
>     }
> }


When I put point after the "m." and try semantic-ia-complete-symbol-menu
(for example) it fails with this message:

Cannot find types for `"m"'


If I try semantic-analyze-current-context, the output indicates that it
encountered this error (full message below):

Method semanticdb-find-tags-by-name-method called on nil


These problems don't occur if I replace the "import java.util.*;" in the
Java file with "import java.utl.Map" and so I'd never encounter them if I
didn't used wildcards in the import statements.

Any idea what's going on here?

I have a Docker image that reproduces this behavior, if anyone's game for
trying it out.  It uses Ubuntu, Emacs 24.5.1, the latest CEDET (as of
2016/09/18), and OpenJDK 8.  If you have Docker installed, you should be
ale to get the image with this command:

docker pull dventimi/docker-emacs


You can then launch a container that opens Emacs on a version of the Java
file with package imports, with this command:

docker run -t -i dventimi/docker-emacs emacs /root/Scratch/HelloWorld2.java


Likewise, you can launch a container that opens Emacs on a version of the
Java file without package imports, with this command:

docker run -t -i dventimi/docker-emacs emacs /root/Scratch/HelloWorld.java


The Semantic Analyzer works in the second case, but not in the first case.
I've been groping my way through this with the debugger, and will continue
to do so, but I thought I'd throw this out there to see if anyone else has
a clue as to what the problem might be.  Thanks!

Best,
David

====== Output of semantic-analyze-current-context =======

Context Type: #<semantic-analyze-context context>
Bounds: (186 . 186)
Prefix: "m"
        ""
Prefix Classes: 'function
                'variable
                'type
Prefix Types: <none>
Encountered Errors: '(error "Method semanticdb-find-tags-by-name-method
called on nil")
--------
-> ScopeTypes: class HelloWorld2
-> Parents: class HelloWorld2
-> Scope: void main(String[])
-> Local Args: String[] args
-> Local Vars: String[] args
                this
               Map m

--001a113cc00ac3705e053cccc670
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi!<div><br></div><div>I&#39;m having trouble with the Sem=
antic Analyzer and &quot;package imports&quot; for Java programs.=C2=A0 I&#=
39;ve an example Java program that looks like this:</div><div><br></div><di=
v><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;borde=
r-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204)=
;padding-left:1ex"><font face=3D"monospace, monospace">import java.util.*;<=
br>import java.util.HashMap;<br>public class HelloWorld2 {<br>=C2=A0 =C2=A0=
 public static void main (String[] args) {<br><span class=3D"gmail-Apple-ta=
b-span" style=3D"white-space:pre">	</span>System.out.println(&quot;Hello, W=
orld!&quot;);<br><span class=3D"gmail-Apple-tab-span" style=3D"white-space:=
pre">	</span>Map m =3D new HashMap();<br><span class=3D"gmail-Apple-tab-spa=
n" style=3D"white-space:pre">	</span>m.<br>=C2=A0 =C2=A0 }<br>}</font></blo=
ckquote></div><div><br></div><div>When I put point after the &quot;m.&quot;=
 and try <font face=3D"monospace, monospace">semantic-ia-complete-symbol-me=
nu</font> (for example) it fails with this message:</div><div><br></div><bl=
ockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-lef=
t-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padd=
ing-left:1ex">Cannot find types for `&quot;m&quot;&#39;</blockquote><div><b=
r></div><div>If I try <font face=3D"monospace, monospace">semantic-analyze-=
current-context</font>, the output indicates that it encountered this error=
 (full message below):</div><div><br></div><blockquote class=3D"gmail_quote=
" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style=
:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><font face=3D"m=
onospace, monospace">Method semanticdb-find-tags-by-name-method called on n=
il</font></blockquote><div><br></div><div>These problems don&#39;t occur if=
 I replace the &quot;import java.util.*;&quot; in the Java file with &quot;=
import java.utl.Map&quot; and so I&#39;d never encounter them if I didn&#39=
;t used wildcards in the import statements. =C2=A0</div><div><br></div><div=
>Any idea what&#39;s going on here?</div><div><br></div><div>I have a Docke=
r image that reproduces this behavior, if anyone&#39;s game for trying it o=
ut.=C2=A0 It uses Ubuntu, Emacs 24.5.1, the latest CEDET (as of 2016/09/18)=
, and OpenJDK 8.=C2=A0 If you have Docker installed, you should be ale to g=
et the image with this command:</div><div><br></div><blockquote class=3D"gm=
ail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-l=
eft-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><font =
face=3D"monospace, monospace">docker pull dventimi/docker-emacs</font></blo=
ckquote><div><br></div><div>You can then launch a container that opens Emac=
s on a version of the Java file with package imports, with this command:</d=
iv><div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px=
 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:=
rgb(204,204,204);padding-left:1ex"><font face=3D"monospace, monospace">dock=
er run -t -i dventimi/docker-emacs emacs /root/Scratch/HelloWorld2.java</fo=
nt></blockquote><div><br></div><div>Likewise, you can launch a container th=
at opens Emacs on a version of the Java file without package imports, with =
this command:</div><div><br></div><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;=
border-left-color:rgb(204,204,204);padding-left:1ex"><font face=3D"monospac=
e, monospace">docker run -t -i dventimi/docker-emacs emacs /root/Scratch/He=
lloWorld.java</font></blockquote><div><br></div><div>The Semantic Analyzer =
works in the second case, but not in the first case.=C2=A0 I&#39;ve been gr=
oping my way through this with the debugger, and will continue to do so, bu=
t I thought I&#39;d throw this out there to see if anyone else has a clue a=
s to what the problem might be.=C2=A0 Thanks!</div><div><br></div><div>Best=
,</div><div>David</div><div><br></div><div><font face=3D"monospace, monospa=
ce">=3D=3D=3D=3D=3D=3D Output of semantic-analyze-current-context =3D=3D=3D=
=3D=3D=3D=3D</font></div><div><br></div><div><div><font face=3D"monospace, =
monospace">Context Type: #&lt;semantic-analyze-context context&gt;</font></=
div><div><font face=3D"monospace, monospace">Bounds: (186 . 186)</font></di=
v><div><font face=3D"monospace, monospace">Prefix: &quot;m&quot;</font></di=
v><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 &quo=
t;&quot;</font></div><div><font face=3D"monospace, monospace">Prefix Classe=
s: &#39;function</font></div><div><font face=3D"monospace, monospace">=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &#39;variable</font></=
div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 &#39;type</font></div><div><font face=3D"monosp=
ace, monospace">Prefix Types: &lt;none&gt;</font></div><div><font face=3D"m=
onospace, monospace">Encountered Errors: &#39;(error &quot;Method semanticd=
b-find-tags-by-name-method called on nil&quot;)</font></div><div><font face=
=3D"monospace, monospace">--------</font></div><div><font face=3D"monospace=
, monospace">-&gt; ScopeTypes: class HelloWorld2</font></div><div><font fac=
e=3D"monospace, monospace">-&gt; Parents: class HelloWorld2</font></div><di=
v><font face=3D"monospace, monospace">-&gt; Scope: void main(String[])</fon=
t></div><div><font face=3D"monospace, monospace">-&gt; Local Args: String[]=
 args</font></div><div><font face=3D"monospace, monospace">-&gt; Local Vars=
: String[] args</font></div><div><font face=3D"monospace, monospace">=C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 this</font></div><div><fo=
nt face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0Map m</font></div></div><div><br></div></div>

--001a113cc00ac3705e053cccc670--


--===============3599484180320812026==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------

--===============3599484180320812026==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
cedet-semantic mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cedet-semantic

--===============3599484180320812026==--