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
Depends on:
Reported: 2006-11-07 17:54 UTC by Jesse Glick
Modified: 2015-04-16 20:13 UTC (History)
1 user (show)

See Also:
Exception Reporter:


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:

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:


('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