This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
The editor wants to replace: _w = new Writer() { public void write(char[] cbuf, int off, int len) {} public void close() {} public void flush() {} }; with: _w = new Writer() { public void write(char[] cbuf, int off, int len) {} public void close() {} public void flush() {} public Appendable append(CharSequence csq) throws IOException { throw new UnsupportedOperationException("Not supported yet."); } public Appendable append(CharSequence csq, int start, int end) throws IOException { throw new UnsupportedOperationException("Not supported yet."); } public Appendable append(char c) throws IOException { throw new UnsupportedOperationException("Not supported yet."); } }; for both jdk1.5 and jdk1.6 The first is not a compile error.
Sorry, but I do not understand what exactly you see and where is the problem. Could you please describe in detail what you see and what is the problem? Thanks.
The problem is that the editor shows an error/lightblub when I type the first code (mentioned in the defect) I let the editor do an "autocomplete" and it fills in the second code (mentioned in the defect) public Appendable append(CharSequence csq) throws IOException; public Appendable append(CharSequence csq, int start, int end)throws IOException; public Appendable append(char c) throws IOException; are not abstract methods that need to be statisfied for java.io.Writer.
Sorry, I cannot reproduce your issue. For me, both Code Completion and 'Implement Abstract methods' supply write(), flush() and close() as expected. Are you sure you're importing java.io.Writer properly?
This still happens with: Product Version: NetBeans IDE Dev (Build 200710150000) Java: 1.6.0_03; Java HotSpot(TM) Client VM 1.6.0_03-b05 System: Linux version 2.6.22.9-slh-smp-1 running on i386; UTF-8; en_US (nb) Userdir: /home/sasbeb/.netbeans/dev Here is my class package com.sas.analytics.cmp.log; import java.io.OutputStream; import java.io.PrintStream; import java.io.PrintWriter; import java.io.Writer; public final class NullOutput { private OutputStream _os; private PrintStream _ps; private Writer _w; private PrintWriter _pw; private static NullOutput _no = new NullOutput(); private NullOutput() { _os = new OutputStream() {public void write(int b) {}}; _ps = new PrintStream(_os); _w = new Writer() { public void write(char[] cbuf, int off, int len) {} public void close() {} public void flush() {} }; _pw = new PrintWriter(_w); }; public static OutputStream getOutputStream() {return _no._os;} public static PrintStream getPrintStream() {return _no._ps;} public static Writer getOutputWriter() {return _no._w;} public static PrintWriter getPrintWriter() {return _no._pw;} }
The auto complete/fix thing creates: package com.sas.analytics.cmp.log; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import java.io.PrintWriter; import java.io.Writer; public final class NullOutput { private OutputStream _os; private PrintStream _ps; private Writer _w; private PrintWriter _pw; private static NullOutput _no = new NullOutput(); private NullOutput() { _os = new OutputStream() {public void write(int b) {}}; _ps = new PrintStream(_os); _w = new Writer() { public void write(char[] cbuf, int off, int len) {} public void close() {} public void flush() {} public Appendable append(CharSequence csq) throws IOException { throw new UnsupportedOperationException("Not supported yet."); } public Appendable append(CharSequence csq, int start, int end) throws IOException { throw new UnsupportedOperationException("Not supported yet."); } public Appendable append(char c) throws IOException { throw new UnsupportedOperationException("Not supported yet."); } }; _pw = new PrintWriter(_w); }; public static OutputStream getOutputStream() {return _no._os;} public static PrintStream getPrintStream() {return _no._ps;} public static Writer getOutputWriter() {return _no._w;} public static PrintWriter getPrintWriter() {return _no._pw;} }
Product Version: NetBeans IDE Dev (Build 071023) Java: 1.5.0_10; Java HotSpot(TM) Client VM 1.5.0_10-b03 System: Linux version 2.6.16.27-0.9-smp running on i386; UTF-8; en_US (nb) It works for me. The only hint it offers for _w = new Writer() { line is the Convert Anonymous to Inner. Even if I delete all methods of the Writer the Implement all abstract methods hint generates _w = new Writer() { @Override public void write(char[] cbuf, int off, int len) throws IOException { throw new UnsupportedOperationException("Not supported yet."); } @Override public void flush() throws IOException { throw new UnsupportedOperationException("Not supported yet."); } @Override public void close() throws IOException { throw new UnsupportedOperationException("Not supported yet."); } }; as expected. Closing as WORKSFORME.
I can reproduce it every single time. Is there a log that NB produces that cen help with this? What platform are you using this on?
..BTW I don't have a classpath environment variable set, nor gcj installed, so there shouldn't be classpath collisions. That's where I'm hoping there's a log file. This problem still occurs in Beta 2.
I use my default platform jdk 1.5 but changing to jdk 1.6 has no effect. The log you can find in /home/sasbeb/.netbeans/dev/var/log/messages.log. You can attach it here. Could you take a screenshot when you click to error/lightbulb? There should be an editor hint name + some tooltip. Please also check your platform in Tools/Options/Java Platform. The Classes tab should list a valid link to rt.jar. Do you use a modified/patched rt.jar?
I use the jdk package from Debian. I'm attaching the Platform Manager screenshot and log And here's the output from NB help Product Version: NetBeans IDE 6.0 Beta 2 (Build 200710212201) Java: 1.6.0_03; Java HotSpot(TM) Client VM 1.6.0_03-b05 System: Linux version 2.6.22.9-slh-smp-1 running on i386; UTF-8; en_US (nb) Userdir: /home/sasbeb/.netbeans/6.0beta2
Created attachment 51585 [details] Tooltip/hint
Created attachment 51586 [details] log file
Really strange! Could you also attach following, please? 1. open /home/sasbeb/.netbeans/dev/var/cache/index/0.5/segments 2. find line <something>=<platform>/jre/lib/rt.jar where <platform> is the java platform used by your project (right click on the project node Properties/Libraries/Java Platform) 3. zip content of /home/sasbeb/.netbeans/dev/var/cache/index/0.5/<something>/classes And the last. Please install NetBeans Project Metadata Inspector in Tools/Plugins/Available Plugins tab. Then right click on you project node and choose the Inspector Project Metadata item. It will dump the project info to the Output window. Attach the content here as well. Thanks for your help.
s58=jar\:file\:/usr/lib/jvm/java-6-sun-1.6.0.03/jre/lib/rt.jar\!/ was the line in the segments file (attaching th zip)
Created attachment 51604 [details] /home/sasbeb/.netbeans/6.0beta2/var/cache/index/0.5/s58
Thanks to Jan Lahoda I can reproduce it now. Please check your project Properties/Sources/Source/Binary Format property. In case I use level JDK 1.4 and lower the issue occurs. The workaround should be to use higher level.
HMMM... Thanks for the info. Our corporate policy is to use 1.4 compatibility. :(
Checking in javac-impl.jar; /cvs/java/source/javacimpl/external/javac-impl.jar,v <-- javac-impl.jar new revision: 1.16; previous revision: 1.15 done Checking in org/netbeans/modules/java/source/TreeLoader.java; /cvs/java/source/src/org/netbeans/modules/java/source/TreeLoader.java,v <-- TreeLoader.java new revision: 1.9; previous revision: 1.8 done Checking in org/netbeans/modules/java/source/usages/Index.java; /cvs/java/source/src/org/netbeans/modules/java/source/usages/Index.java,v <-- Index.java new revision: 1.20; previous revision: 1.19 done Checking in org/netbeans/modules/java/source/usages/RepositoryUpdater.java; /cvs/java/source/src/org/netbeans/modules/java/source/usages/RepositoryUpdater.java,v <-- RepositoryUpdater.java new revision: 1.102; previous revision: 1.101 done Checking in org/netbeans/modules/java/source/usages/SourceAnalyser.java; /cvs/java/source/src/org/netbeans/modules/java/source/usages/SourceAnalyser.java,v <-- SourceAnalyser.java new revision: 1.17; previous revision: 1.16 done Checking in org/netbeans/modules/java/source/usages/SymbolClassReader.java; /cvs/java/source/src/org/netbeans/modules/java/source/usages/SymbolClassReader.java,v <-- SymbolClassReader.java new revision: 1.15; previous revision: 1.14 done Checking in org/netbeans/modules/java/source/usages/SymbolDumper.java; /cvs/java/source/src/org/netbeans/modules/java/source/usages/SymbolDumper.java,v <-- SymbolDumper.java new revision: 1.8; previous revision: 1.7 done
Thanks for the report, the root case of the problem was really bad - the class reader wrongly handled covariant return types in JDK 1.4. Because the NetBeans is written in the JDK 5 no one here found this problem before. Thanks again. Tomas
Fixes to prevent NPE from TransTypes caused by fix of this issue, see #120383: Checking in javac-impl.jar; /cvs/java/source/javacimpl/external/javac-impl.jar,v <-- javac-impl.jar new revision: 1.17; previous revision: 1.16 done Checking in org/netbeans/modules/java/source/usages/Index.java; /cvs/java/source/src/org/netbeans/modules/java/source/usages/Index.java,v <-- Index.java new revision: 1.21; previous revision: 1.20 done Checking in org/netbeans/modules/java/source/usages/SymbolDumper.java; /cvs/java/source/src/org/netbeans/modules/java/source/usages/SymbolDumper.java,v <-- SymbolDumper.java new revision: 1.10; previous revision: 1.9 done
Works as advertised in rc1. Great job.