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 88860 - Distinctive highlighting of compile-time constants
Summary: Distinctive highlighting of compile-time constants
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Rastislav Komara
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-07 17:54 UTC by Jesse Glick
Modified: 2015-04-16 20:13 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2006-11-07 17:54:14 UTC
Constants are treated specially in the Java language, as usages are inlined by
the compiler rather than compiled to field accesses:

http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#5313
http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#10931
http://java.sun.com/docs/books/jls/third_edition/html/binaryComp.html#13.4.9

I think they should be given a distinctive highlight mode, rather than being
treated as fields. In particular, in the following class,

import java.util.Date;
public class CompileTimeConstants {
    static String a = "a";
    static final String b = "b";
    static final String c = new String("c");
    String d = "d";
    final String e = "e";
    final String f = new String("f");
    static final Object g = "g";
    public static final int SEVENTEEN = 17;
    interface I {
        String OTHERNAME = "goodbye";
        int TEN = 10;
        Object OH = new Object();
        String COMPUTED = new Date().toString();
        boolean debug = new Boolean(true).booleanValue();
    }
}

the following fields are in fact constants:

b e SEVENTEEN OTHERNAME TEN

('e' is a constant even though nonstatic - that is permitted.) 'a' is not final,
'c' is not initialized with a constant expression, 'g' is not declared to be of
primitive or String type, etc.

I am not sure offhand what coloring to use for constants, but perhaps simply
bold (black) would suffice to distinguish them from regular fields. Of course
usages as well as declarations should be highlighted in the same way, e.g.

double r = ...;
double area = Math.PI * r * r;
                   ^^
Comment 1 Jesse Glick 2006-11-07 18:06:09 UTC
Also see issue #88861 re. enum "constants".
Comment 2 Rastislav Komara 2009-02-03 10:54:32 UTC
Overtake.