Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Eclipse, Java 1.5 and StringBuffer
Hello,

Java 1.5(for whatever reason) has added covariant return types ie

C:\>javap java.lang.StringBuffer
Compiled from "StringBuffer.java"
public final class java.lang.StringBuffer extends
java.lang.AbstractStringBuilder implements
java.io.Serializable,java.lang.CharSequence{
...
public synchronized java.lang.StringBuffer append(char);
...
public java.lang.AbstractStringBuilder append(char);
...
public java.lang.Appendable append(char) throws
java.io.IOException;
....
}

The eclipse compiler chooses the last one of these meaning the code
will not compile if it does not catch the IOException.

Does anyone have a workaround?

- Robert


Report this thread to moderator Post Follow-up to this message
Old Post
Robert Colquhoun
03-29-04 10:38 AM


Re: Eclipse, Java 1.5 and StringBuffer
On Mon, 29 Mar 2004 09:30:08 GMT, Robert Colquhoun <rjc@trump.net.au>
wrote:

>Does anyone have a workaround?
Upgrade to Eclise M8

Report this thread to moderator Post Follow-up to this message
Old Post
Brian Skaarup
03-29-04 02:45 PM


Re: Eclipse, Java 1.5 and StringBuffer
Robert Colquhoun wrote:

> C:\>javap java.lang.StringBuffer
> Compiled from "StringBuffer.java"
> public final class java.lang.StringBuffer extends
> java.lang.AbstractStringBuilder implements
> java.io.Serializable,java.lang.CharSequence{
> ...
>     public synchronized java.lang.StringBuffer append(char);
> ...
>     public java.lang.AbstractStringBuilder append(char);
> ...
>     public java.lang.Appendable append(char) throws
> java.io.IOException;
> ....

I can't suggest a workaround (other than not trying to use 1.5 classfiles wi
th
a pre-1.5 compiler ;-).

I'm more interested in *why* the compiler has generated that third method at
all.  I can see why it'd generate the first two, but the third seems
unnecessary.

Presumably it's something to do with the fact that it has generated a simila
r
method for AbstractStringBuilder, but I can't see why it's done *that*
either...

A bug ?

-- chris



Report this thread to moderator Post Follow-up to this message
Old Post
Chris Uppal
03-30-04 10:39 AM


Re: Eclipse, Java 1.5 and StringBuffer
Hello Brian,

On Mon, 29 Mar 2004 15:24:51 +0200, Brian Skaarup
<brian@nocannedmeat.skaarup.org> wrote:

>On Mon, 29 Mar 2004 09:30:08 GMT, Robert Colquhoun <rjc@trump.net.au>
>wrote:
> 
>Upgrade to Eclise M8

I have been trying to, all yesterday tried to download it from sole
australia mirror but it kept dropping out around 50mb or so.

I think i need  a download manager of some sort.

Currently i am using 2.1.3 which was only released a couple of ws
ago obviously they are not going to add 1.5 support to the 2.1 series.

- Robert

Report this thread to moderator Post Follow-up to this message
Old Post
Robert Colquhoun
03-31-04 08:35 AM


Re: Eclipse, Java 1.5 and StringBuffer
Hello Chris,

On Tue, 30 Mar 2004 10:30:03 +0100, "Chris Uppal"
<chris.uppal@metagnostic.REMOVE-THIS.org> wrote:
>Robert Colquhoun wrote: 
>
>I can't suggest a workaround (other than not trying to use 1.5 classfiles w
ith
>a pre-1.5 compiler ;-).

Yes also might need careful if using a 1.5 compiler targetted for
older jvms.

>I'm more interested in *why* the compiler has generated that third method a
t
>all.  I can see why it'd generate the first two, but the third seems
>unnecessary.

The first is StringBuffer original method(the one i want to link to.

The second is to implement the AbstractStringBuilder interface.

The third is to implement the java.lang.Appendable interface which is
pulled in via AbstractStringBuilder.


>Presumably it's something to do with the fact that it has generated a simil
ar
>method for AbstractStringBuilder, but I can't see why it's done *that*
>either...
>
>A bug ?

No i think they are trying to post-fix problems in the orginal
StringBuffer class ie synchronized methods not fitting being able to
substitute another class instead of StringBuffer implementation(no
interface).

It is kind of looking a bit of a mess now though.

- Robert

Report this thread to moderator Post Follow-up to this message
Old Post
Robert Colquhoun
03-31-04 09:55 AM


Re: Eclipse, Java 1.5 and StringBuffer
Robert Colquhoun wrote:
 
>
> The first is StringBuffer original method(the one i want to link to.
>
> The second is to implement the AbstractStringBuilder interface.
>
> The third is to implement the java.lang.Appendable interface which is
> pulled in via AbstractStringBuilder.

But the last is unecessary.  At least, *I* don't understand why the compiler
thinks it needs to generate it (or even why it thinks it is *allowed* to
generate it).


> It is kind of looking a bit of a mess now though.

I agree -- though I suspect we are talking about slightly different things ;
-)

-- chris



Report this thread to moderator Post Follow-up to this message
Old Post
Chris Uppal
03-31-04 05:39 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Programmer archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:54 PM.

 

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.