From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5b27ffedba54a4a2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-03-02 11:38:06 PST Path: supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: JGNAT and Null references Date: 02 Mar 2001 14:27:57 -0500 Organization: NASA Goddard Space Flight Center Message-ID: References: <3A9E77D4.D40FEAA@earthlink.net> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 983562108 14646 128.183.220.71 (2 Mar 2001 19:41:48 GMT) X-Complaints-To: dscoggin@cne-odin.gsfc.nasa.gov NNTP-Posting-Date: 2 Mar 2001 19:41:48 GMT User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.6 Xref: supernews.google.com comp.lang.ada:5383 Date: 2001-03-02T19:41:48+00:00 List-Id: "Marc A. Criley" writes: > Let me just plow right into an annotated example here, rather than > trying to explain it first... > > The Java class javax.swing.JTabbedPane provides a method called addTab > that looks like this: > > public void addTab(String title, > Icon icon, > Component component, > String tip) > > When this class is run through JGNAT's jvm2ada, the Ada equivalent of > that method is: > > procedure addTab (This : access Typ; > P1_String : access java.lang.String.Typ'Class; > P2_Icon : access javax.swing.Icon.Typ'Class; > P3_Component : access java.awt.Component.Typ'Class; > P4_String : access java.lang.String.Typ'Class); > > Okay, so far so good. > > In Java, if I don't have an icon to accompany this tab pane, I can just > supply that parameter with a null: > > jtp.addTab("My title", null, a_component, "a_tool_tip"); > > Attempting this in Ada: > > AddTab(Jtp, +"My title", null, A_Component, +"a_tool_tip"); > > generates an error when compiled: > > null cannot be of an anonymous access type This is a bug in jvm2ada; if addTab can accept "null" for Icon, the Ada version should not be an access parameter, it should be an "in" parameter of an access type. I'm not clear how jvm2ada can tell whether "null" is valid; seems like it would have to read the body of the class, or the programmer's mind, or something. Apparently it just assumes "null" is never valid. Report it to report@gnat.com. In the meantime, you can probably just edit the spec where AddTab is defined, to pass an "in" parameter of an appropriate access type, which can then be "null". Not fun, but it should work. > What > do I provide as a "null argument" in JGNAT? I was hoping to find some > sort of predefined "null_reference" constant, analogous to > System.Null_Address, but no such luck. You can't pass "null", in any form. Defining it as a constant won't work; the compiler is smarter than that! If you don't want to edit the spec for AddTab, you will have to define an Icon somewhere (but don't ask me how), and pass that instead of null. -- -- Stephe