Duplicate case label : IDE Bug?

Hello,

I am experiencing a "Duplicate case Label" using this code in a win-1252 codepage :

        for (int cnt = 0; cnt < nrOfChars; cnt++) {
            ch = someText.toLowerCase().charAt(cnt);
            switch (ch) {
                case 'ä':
                    res.append("AE");
                    break;
                case 'ö':
                    res.append("OE");
                    break;
                case 'ü':
                    res.append("UE");
                    break;
                default:
                    res.append(ch);
                    break;
            }
        }


This appears to me like an bug, the prior version of the code also threw this error :



        for (int cnt = 0; cnt < nrOfChars; cnt++) {
            ch = someText.charAt(cnt);
            switch (ch) {
                case 'Ä':
                    res.append("AE");
                case 'ä':
                    res.append("AE");
                    break;
                case 'Ö':
                    res.append("OE");
                    break;
                case 'ö':
                    res.append("OE");
                    break;
                case 'Ü':
                    res.append("UE");
                    break;
                case 'ü':
                    res.append("UE");
                    break;
                default:
                    res.append(ch);
                    break;
            }
        }


Thanks in advance!

regards,
Marcus

5 comments
Comment actions Permalink

Hello.

Can't reproduce it, sorry. For me only "magic character" inspection is reported.

Can you attach a small sample project with this bug reproducible?

Thank you,
Alexander.

0
Comment actions Permalink

Same here with very similar code !
I just expunged most of the irrelevant part

 public static String toUpper(String chaine) {


  for (int i = 0; i < chaine.length(); i++) {
    car = chaine.charAt(i);


    switch (car) {
      case 'á':
      case 'Á':
      case 'à':
      case 'À':
      case 'â':
      case 'Â':
      case 'ä':
      case 'Ä':
         car = 'A';
         break;
      default:
         car = Character.toUpperCase(car);
   }


   buf.append(car);
  }


  return buf.toString();
 }

Build is based on MAVEN 3.0.5 Source coude is 1.7, Byte code is 1.7
JetBrainVersion.png

Maven compiles without issue while IntelliJ complains when building the code.
For the sake of the records, I have ISO-8859-1 encoding with CRLF for the End of Lines.

\T,

0
Comment actions Permalink

Hi Alexander,

attaching sample project (single class) which cannot be compiled due to this bug.
Please take a look into it and provide fix if possible.

Below I've added screen capture from the Messages tool window:
CompilationError.png

Cheers,
Mariusz



Attachment(s):
Encoding.zip
0
Comment actions Permalink

Sorry for delay, I was on vacation.

In the attached project the project encoding is set to "System default". Change it to ISO-8859-1, and the compilation will be successful.

Regards,
Alexander.

0
Comment actions Permalink

Thank you Alexander for the tip - my project at work compiles now properly : )
In the future, if you could make such setting autodiscoverable (based on pom?)  it would make Idea even more awesome : )

Cheers!
Mariusz

0

Please sign in to leave a comment.