Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / April 2004

Tip: Looking for answers? Try searching our database.

Return type method syntax

Thread view: 
Adam Warner - 03 Apr 2004 03:34 GMT
Hi all,

I've been looking at some public methods via Sun's javap disassembler and
I find some don't print the return type void, e.g.:

$ javap -public VerifyError
Compiled from "VerifyError.java"
public class java.lang.VerifyError extends java.lang.LinkageError{
   public java.lang.VerifyError();
   public java.lang.VerifyError(java.lang.String);
}

A bytecode disassembly shows both methods conclude with a "return"
mnemonic, which returns void from each method. What is the reason Sun's
disassembler doesn't print this:

Compiled from "VerifyError.java"
public class java.lang.VerifyError extends java.lang.LinkageError{
   public void java.lang.VerifyError();
   public void java.lang.VerifyError(java.lang.String);
}

8.4 of the Java Language Specification (2nd edition) appears clear:
"A method declaration either specifies the type of value that the method
returns or uses the keyword void to indicate that the method does not
return a value."

Could this be a bug in Sun's disassembler output or have I overlooked
something?

Thanks,
Adam
Bjorn Abelli - 03 Apr 2004 11:44 GMT
"Adam Warner" wrote...

> A bytecode disassembly shows both methods conclude with a "return"
> mnemonic, which returns void from each method. What is the reason Sun's
[quoted text clipped - 5 lines]
>     public void java.lang.VerifyError(java.lang.String);
> }

[snip]

> Could this be a bug in Sun's disassembler output or have I overlooked
> something?

You have overlooked that "constructors" are not "methods" in that sense.

// Bjorn A
Adam Warner - 03 Apr 2004 12:44 GMT
Hi Bjorn Abelli,

>> Could this be a bug in Sun's disassembler output or have I overlooked
>> something?
>
> You have overlooked that "constructors" are not "methods" in that sense.

Thanks Bjorn. I had misunderstood that these were constructors (object
builders) rather than methods. As I now understand it constructors build
objects of the class: As they have the same name as the class and the
class is the type, additionally listing the type of the object would be
redundant.

Regards,
Adam


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.