Bug 51353 - The type AbstractStringBuilder is not visible
Summary: The type AbstractStringBuilder is not visible
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal with 2 votes (vote)
Target Milestone: 3.0 M8   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 51707 51864 52979 54673 56277 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-02-09 05:19 EST by Rémi Forax CLA
Modified: 2007-11-19 04:54 EST (History)
8 users (show)

See Also:


Attachments
.. (84.00 KB, patch)
2007-11-19 04:03 EST, hoya CLA
no flags Details | Diff
.. (84.00 KB, patch)
2007-11-19 04:04 EST, hoya CLA
no flags Details | Diff
... (84.00 KB, application/octet-stream)
2007-11-19 04:05 EST, hoya CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rémi Forax CLA 2004-02-09 05:19:53 EST
In JDK1.5, StringBuffer have been refactored and now
inherits from AbstractStringBuilder.

The AbstractStringBuilder have a lot method append
that return an AbstractStringBuilder.
In the class, StringBuffer all this methods have
their counterparts that return a StringBuffer.

The problems comes when you try to use one of this
append method. example

new StringBuffer().append(1);

The eclipse compiler returns an error
"The type AbstractStringBuilder is not visible".
I think its an error in compiler method lookup
that prefers AbstractStringBuilder.append(int) to
StringBuffer.append(int).

I think this is a major bug 'cause programmer cannot
test jdk1.5 api.
Comment 1 Philipe Mulet CLA 2004-02-12 18:40:29 EST
The problem comes from the fact our compiler isn't 1.5 yet. 
StringBuffer defines alternate methods with distinct return types. These are 
bridge methods used to perform mapping at runtime (which cares about return 
types in signature).

--> java.lang.AbstractStringBuilder append(java.lang.String) 
    java.lang.StringBuffer append(java.lang.String) 

--> java.lang.Appendable append(char) throws java.io.IOException
    java.lang.StringBuffer append(char[]) 

The 1.4 compiler doesn't expect this scenario, and thus incorrectly pick the 
wrong method (due to ordering of methods in classfile). Extra checks are 
necessary so as to select the proper method.
Comment 2 Philipe Mulet CLA 2004-02-12 18:41:39 EST
*** Bug 51864 has been marked as a duplicate of this bug. ***
Comment 3 Philipe Mulet CLA 2004-02-13 06:18:03 EST
Fix is to filter out bridge methods (as synthetics) from binary bindings.
This could be applied to HEAD stream independently from 1.5 branch, since it 
will not impact existing code.
Comment 4 Philipe Mulet CLA 2004-02-13 06:21:11 EST
One thing which is troublesome is that the 1.5 spec seems to have changed the 
value of ACC_SYNTHETIC from 0x20000 to 0x1000, which will render all libraries 
compiled with <1.5 compilers obsolete (as <1.5 generated synthetics are no 
longer recognized as such by 1.5 standards).

We may want to consider both values as synthetic for backward compatibility...
Comment 5 Philipe Mulet CLA 2004-02-13 07:04:19 EST
Actually, ACC_SYNTHETIC does not cause grief. It was not a public flag in the 
past, only an attribute. We can make it reflect the new value, and convert 
attribute to modifiers from 1.5 on.

No need to check for bridge methods, as these are also marked as synthetics.
Fixed by simply setting AccSynthetic to 0x1000.
Comment 6 Philipe Mulet CLA 2004-02-13 07:05:01 EST
Fixed
Comment 7 Philipe Mulet CLA 2004-03-08 18:24:47 EST
*** Bug 51707 has been marked as a duplicate of this bug. ***
Comment 8 Philipe Mulet CLA 2004-03-08 18:27:49 EST
*** Bug 52979 has been marked as a duplicate of this bug. ***
Comment 9 Philipe Mulet CLA 2004-03-15 12:23:58 EST
*** Bug 54673 has been marked as a duplicate of this bug. ***
Comment 10 Jerome Lanneluc CLA 2004-03-24 13:03:30 EST
Verified in build I200403240800.
Comment 11 Olivier Thomann CLA 2004-03-25 21:35:39 EST
*** Bug 56277 has been marked as a duplicate of this bug. ***
Comment 12 trevor campbell CLA 2006-02-19 19:58:11 EST
This bug seems to have reappeared in 3.2 M5 release.  I upgraded from M4 to M5 (Version: 3.2.0 Build id: I20060217-1115) and get both:
"The type AbstractStringBuilder is not visible" and
"Unhandled exception type IOException"
wherever I use StringBuffer.append() methods.

I am using:
"java version "1.5.0_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)"

If I swap to:
"java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2)"
the errors disappear.
	
Comment 13 Philipe Mulet CLA 2006-02-20 04:06:45 EST
This is likely a consequence of fixing bug 124943.
Kent - pls have a look, and file a new bug report if needed.
Comment 14 Kent Johnson CLA 2006-02-20 11:04:51 EST
Trevor, can you provide a testcase?

When I try a simple case with new StringBuffer().append(1), it works fine in 1.4 & 5.0 modes.
Comment 15 trevor campbell CLA 2006-02-20 19:17:12 EST
I cannot reproduce this in a standalone test case.  The following is code that fails in my large project.

public class Testm5a
{

    public String test()
    {
        char ch = 'a';
        
        StringBuffer addressStr = new StringBuffer();
        
        // This causes The type AbstractStringBuilder is not visible
        addressStr.append("AAAA").append("AAAAA");
        
        // This gives unhandled exception IO exception
        addressStr.append(ch);
        
        return addressStr.toString();
    }
    
}

From my testing in my large project the error only seems to occur when I use buff.append().append();.  If I break the code to use buff.append(); buff.append(); the error does not occur.  And the IO Exception only seems to come from the append(char ch) method.

My project giving the error is part of a set of about 15 related projects that I created under M4 release.  I have now also taken a copy of my source and created a new single project and the errors disappear, but when I recreated the set of original projects the errors remained. 


Comment 16 Frederic Fusier CLA 2006-04-20 13:29:17 EDT
Cannot reproduce with 3.2 RC1 and comment 15 test case...
I've also verified all duplicate and everything is fine
=> close as WORKSFORME

Comment 17 Frederic Fusier CLA 2006-04-20 13:30:03 EDT
Sorry, WORKSFORME is not a correct resolution
Comment 18 Frederic Fusier CLA 2006-04-20 13:30:33 EDT
It should be FIXED, as this issue is still considered as fixed...
Comment 19 sayanshines CLA 2007-02-07 00:20:12 EST
(In reply to comment #18)
> It should be FIXED, as this issue is still considered as fixed...

From above discussions, it's not clear if the issue is resolved in eclipse 1.5.
In my J2EE-project, I've lots of StringBuffers for holding the SQL-query constants. So, if the issue is not fixed, it will be mammoth task to break the stringBuffer.append().append().
Please suggest something useful.
Thanks much.
Comment 20 Philipe Mulet CLA 2007-02-07 06:39:08 EST
Our understanding is that the problem got fixed, and last raised issues were not reproducible. If you believe you have found an issue, then please open another defect, since this one has long lived. 
Remember to add steps to reproduce, since this was the lack of steps which made the last raised issues useless.
Comment 21 hoya CLA 2007-11-19 04:03:03 EST
Created attachment 83216 [details]
..
Comment 22 hoya CLA 2007-11-19 04:04:45 EST
Created attachment 83217 [details]
..
Comment 23 hoya CLA 2007-11-19 04:05:58 EST
Created attachment 83218 [details]
...
Comment 24 Philipe Mulet CLA 2007-11-19 04:54:22 EST
What's going on hoya ?