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.

Bug 193476 - I18N: regression - Unable to open java source files when project encoding is set to non UTF-8 encoding
Summary: I18N: regression - Unable to open java source files when project encoding is ...
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Text (show other bugs)
Version: 7.0
Hardware: All All
: P1 normal (vote)
Assignee: David Strupl
URL:
Keywords: I18N, REGRESSION
: 193980 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-12-16 05:24 UTC by watanabe-fumika
Modified: 2011-02-10 06:08 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
sample projects with several encoding (37.59 KB, application/zip)
2011-01-15 04:56 UTC, Masaki Katakai
Details

Note You need to log in before you can comment on or make changes to this bug.
Description watanabe-fumika 2010-12-16 05:24:56 UTC
Product Version = NetBeans IDE Dev (Build 201012150001)
Operating System = Windows XP version 5.1 running on x86
Java; VM; Vendor = 1.6.0_22
Runtime = Java HotSpot(TM) Client VM 17.1-b03
SEVERE [org.openide.util.Exceptions]
msg
Caused: java.lang.IllegalStateException: Current state = FLUSHED, new state = CODING
        at java.nio.charset.CharsetDecoder.throwIllegalStateException(CharsetDecoder.java:951)
        at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:537)
        at org.netbeans.api.queries.FileEncodingQuery$ProxyCharset$ProxyDecoder.decodeLoop(FileEncodingQuery.java:192)
        at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:544)
        at org.netbeans.api.queries.FileEncodingQuery$ProxyCharset$ProxyDecoder.implFlush(FileEncodingQuery.java:279)
        at java.nio.charset.CharsetDecoder.flush(CharsetDecoder.java:633)
        at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:769)
        at org.openide.text.DataEditorSupport.checkIfCharsetCanDecodeFile(DataEditorSupport.java:456)
        at org.openide.text.DataEditorSupport.loadFromStreamToKit(DataEditorSupport.java:431)
        at org.openide.text.CloneableEditorSupport.loadDocument(CloneableEditorSupport.java:2156)
        at org.openide.text.CloneableEditorSupport.access$2800(CloneableEditorSupport.java:133)
        at org.openide.text.CloneableEditorSupport$Listener.run(CloneableEditorSupport.java:2986)
        at org.openide.text.CloneableEditorSupport$3.doRun(CloneableEditorSupport.java:710)
        at org.openide.text.CloneableEditorSupport$3.run(CloneableEditorSupport.java:677)
        at org.netbeans.editor.GuardedDocument.runAtomic(GuardedDocument.java:314)
        at org.openide.text.NbDocument.runAtomic(NbDocument.java:422)
        at org.openide.text.CloneableEditorSupport$3.doRun(CloneableEditorSupport.java:687)
        at org.openide.text.CloneableEditorSupport$3.run(CloneableEditorSupport.java:677)
        at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1424)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1968)
ALL [null]: ドキュメント CellColor.java を読み込めませんでした。
Comment 1 Masaki Katakai 2011-01-15 04:54:48 UTC
Set priority to P2.

It's still happen in the latest trunk.

Product Version: NetBeans IDE Dev (Build 201101140000)
Java: 1.6.0_23; Java HotSpot(TM) Client VM 19.0-b09
System: SunOS version 5.11 running on x86; UTF-8; en (nb)

I'm seeing this issue on both Solaris and Windows.

1. Create a Java project with default main.java
2. Set project encoding to UTF-8
3. Close the project and open it again, then open main.java on the editor
   => works fine.

4. Set project encoding to non UTF-8 encoding e.g. windows-31j, EUC-JP, Big5...
5. Close the project and open it again, then open main.java on the editor
   => NetBeans shows "The document XXXX.java could not be locaded." on the dialog.

The same exception happens in the log file.
Comment 2 Masaki Katakai 2011-01-15 04:56:38 UTC
Created attachment 105020 [details]
sample projects with several encoding

Try to open these projects on the latest trunk, then try to open Java source file.
Comment 3 Marian Mirilovic 2011-01-27 11:46:58 UTC
If possible, please fix it for Beta 2, but this is definitely stopper for FCS.
Comment 4 David Strupl 2011-01-31 07:51:31 UTC
Vladimir, any comment on that?
Comment 5 Vladimir Voskresensky 2011-01-31 09:37:34 UTC
*** Bug 193980 has been marked as a duplicate of this bug. ***
Comment 6 Vladimir Voskresensky 2011-01-31 10:13:48 UTC
David, I will have a look
Comment 7 Vladimir Voskresensky 2011-01-31 11:06:58 UTC
David. looks like we've faced with issue Jan asked about before:
"did someone check what will hapen if a multibyte character will span
across the first 1024 bytes boundary?"
check only buffer with 1024 bytes is not enough. 
Right approach is to load file completely.
Workaround could be to add extra catch for such situations:
if (len > 0) {
    try {
        decoder.decode(ByteBuffer.wrap(buffer, 0, len));
    } catch (CharacterCodingException e) {
        ERR.log(Level.FINE, "Encoding problem using " + charset, e); // NOI18N
        return false;
    } catch (IllegalStateException e) {
        ERR.log(Level.FINE, "Encoding problem using " + charset, e); // NOI18N
        if (!e.getMessage().contains("CODING_END")) {
            return false;
        }
    }
}
Comment 8 David Strupl 2011-01-31 12:23:52 UTC
I will add the catch now. Ok?
Comment 9 David Strupl 2011-01-31 12:38:05 UTC
http://hg.netbeans.org/jet-main/rev/0afd2f872a5e
Comment 10 watanabe-fumika 2011-02-10 06:04:57 UTC
The Problem confirmed the correction by build 201102010000.
Comment 11 watanabe-fumika 2011-02-10 06:08:26 UTC
(In reply to comment #10)
> The Problem confirmed the correction by build 201102010000.
Is there a usage of the comment?