jsr341-experts@el-spec.java.net

[jsr341-experts] Static fields, part 2

From: Kin-man Chung <kinman.chung_at_oracle.com>
Date: Mon, 22 Aug 2011 16:32:36 -0700

We have agreed on the syntax:

     T(java.lang.Boolean).TRUE

Now we need to add a couple of classes for the implementation.

1. javax.el.ELClass

This is the runtime representation of T(...). This object cannot be
directly manipulated by the user, and is used only in
StatiFieldELResolver, described below. The class java.lang.Class is not
used here to avoid confusion.

2. StaticFieldELResolver

Resolve the expression T(...).f. In the method getValue(Object base,
Object property), if base is an instance of javax.el.ELClass, and if f
is a string whose value is

    a. "class", resolves to the java.lang.Class object of this class
represent by T(...), or
    b. the name of a public static field or method for the class,
resolves to the value of the static field or method, or
    c. a enum constant for the class, resolves to the value of the enum
constant.

I'll update the wiki to add these 2 classes, once they are actually
implemented.

As a side note, I have briefly toyed with the ideas that we should allow
referencing of static fields (or even instant field) from a bean, such as

    bean.f

but have rejected it for fear of causing confusion with bean properties.

Kin-man