(Answer) (Category) FAQ-O-Matic : (Category) General : (Category) Compiler : (Category) Javac VS JBuilder's bcj :
Case statement #1
KeyEvent p_ev; ...
switch(p_ev.getKeyCode()) {
          case p_ev.VK_UP: {           <- line 131
            setValue(++value);
            break;
          }
          case p_ev.VK_DOWN: {
            setValue(--value);
            break;
          }
        }
"JSpinner.java": Error #: 409 : constant expression required at line 131, column 21

John McGrath writes:

JBuilder is correctly reporting an error in your code. The expression in a case label must be a compile-time constant expression. According to the Java Language Specification, if you reference a static final variable using an object reference, that is not considered a compile time constant. However if you reference the variable using the class name, then it is considered a constant expression. So it should compile without error if you change your code to:

           case KeyEvent.VK_UP:

Note that when you specify the JDK for JBuilder to use, that only affects the runtime classes that it uses to compile with. JBuilder always uses its own compiler.

I presume that when you compiled from the command line, you were using the javac compiler from JDK 1.2. If you compile the same code with the javac from JDK 1.3, it will report an error as well. Sun fixed the bug in their compiler with the 1.3 release.


2001-Feb-15 1:43pm gyles19@visi.com

[Append to This Answer]
2001-Feb-15 1:43pm
Next: (Answer) Usage of this$0
This document is: http://www.visi.com/~gyles19/cgi-bin/fom.cgi?file=92
[Search] [Appearance]
This is a Faq-O-Matic 2.709.
This FAQ administered by gyles19@visi.com.

Other JBuilder Links

Java Community
Java Tools
Code Central
JB OpenTools
Community
Recent
Threads
Borland Chat
Chat FAQ
Feature Matrices
3.0 |  3.5 |  4.0
5.0 |  6.0 |  7.0
Shop for
JBuilder
JBuilder
Downloads
and reg keys
Report Piracy
Online Manuals
4.0 |  5.0 |  6.0
7.0
Borland
DevSupport's
Bug/RFE Form

Quality Central Client
JB Patches &
Updates
JBuilder FAQs TIs
JBuilder
Newsgroups
Tamaracka's
News Archive
Mr. Haki's
JBuilder Machine
JGuru's
JBuilder FAQ
Sun's Bug
Parade
Netring Home - About - Privacy
The
JBuilder Netring Logo
The Borland JBuilder Netring by JBuilder FAQ-O-Matic
[ Join Now | List Sites | Random | << Prev | Next >> ]
[ Previous 5 Sites | Skip Previous | Skip Next | Next 5 Sites ]