<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1846725363010306463</id><updated>2011-12-26T17:47:20.134+02:00</updated><category term='rest'/><category term='jcp'/><category term='kijaro'/><category term='java6'/><category term='macos'/><category term='webbeans'/><category term='jsf'/><category term='java'/><category term='artifactory'/><category term='jpa'/><category term='ejb3'/><category term='javaone'/><category term='financial crisis'/><category term='stellarium'/><category term='sun'/><category term='weblogic'/><category term='jersey'/><category term='UI'/><category term='abstract enum'/><category term='architecture'/><category term='oracle'/><category term='properties'/><category term='openjdk'/><category term='wild'/><title type='text'>Fred, Let it go!</title><subtitle type='html'>Mainly about Java, Open Source and the OpenJDK</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>33</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-3747949718083900916</id><published>2011-07-05T18:43:00.002+03:00</published><updated>2011-07-05T18:48:48.877+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='abstract enum'/><category scheme='http://www.blogger.com/atom/ns#' term='openjdk'/><title type='text'>Extended Enums usage</title><content type='html'>Since the re-launch of extended enums I'm paying attention in my everyday coding (yes I still write code :) if extended enums will help me.&lt;br /&gt;Here are 2 new examples:&lt;br /&gt;1) I found out that most of the time the name() of the enum is not what I need. I need it to map an XML or HTML tag, an external ID, an entry name in excel or simple type name in a JSON object. So I write something like:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;    public enum ConfigName {&lt;br /&gt;        ALL("local-all"),&lt;br /&gt;        INTERNAL("local-int"),&lt;br /&gt;        OR("local-int-ext");&lt;br /&gt;&lt;br /&gt;        private final String xmlKey;&lt;br /&gt;&lt;br /&gt;        LdapConfig(String xmlKey) {&lt;br /&gt;            this.xmlKey = xmlKey;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public String getXmlKey() {&lt;br /&gt;            return xmlKey;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I could remove the getter, and the IDE helping a lot writing the boiler plate code but why? Here is how it should look:&lt;br /&gt;&lt;pre&gt;    public enum ConfigName extends AlternateEnumKey {&lt;br /&gt;        ALL("local-all"),&lt;br /&gt;        INTERNAL("local-int"),&lt;br /&gt;        OR("local-int-ext");&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The extra feature here is that the name() of the enum (ALL, INTERNAL, OR) is a constant that is not recognized as such by the javac compiler. So:&lt;br /&gt;&lt;pre&gt;    @XmlTag(tag = ConfigName.ALL)&lt;/pre&gt;&lt;br /&gt;will not compile and so:&lt;br /&gt;&lt;pre&gt;    @XmlTag(tag = ConfigName.ALL.xmlKey)&lt;/pre&gt;&lt;br /&gt;will for sure not.&lt;br /&gt;&lt;br /&gt;But with extended enum you'll have:&lt;br /&gt;&lt;pre&gt;    public @interface XmlTag { AlternateEnumKey tag(); }&lt;br /&gt;&lt;br /&gt;    // The framework managing XmlTag will take the alternate key value&lt;br /&gt;    @XmlTag(tag = ConfigName.ALL)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;2) Since extended enums also supports generics for enums, and I just have this issue associating also a long (ID) to an enums, you can now write:&lt;br /&gt;&lt;pre&gt;    public enum ConfigName extends EnumPairExtension&amp;lt;Long, String&amp;gt; {&lt;br /&gt;        ALL(45L, "local-all"),&lt;br /&gt;        INTERNAL(56L, "local-int"),&lt;br /&gt;        OR(98L, "local-int-ext");&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    assert ConfigName.OR.a == 98L;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;With this, parsing definitions are a lot cleaner to write.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-3747949718083900916?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/3747949718083900916/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=3747949718083900916' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/3747949718083900916'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/3747949718083900916'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2011/07/extended-enums-usage.html' title='Extended Enums usage'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-2140059330018711382</id><published>2011-06-14T15:35:00.002+03:00</published><updated>2011-06-14T15:39:37.969+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='abstract enum'/><category scheme='http://www.blogger.com/atom/ns#' term='kijaro'/><category scheme='http://www.blogger.com/atom/ns#' term='openjdk'/><title type='text'>A new push for extended enums!</title><content type='html'>At Devoxx09, Joe Darcy presented the status and future of the Coin project, and how changes to the language are selected and implemented (or vice versa). :)&lt;br /&gt;During his talk, he showed the cost classification of a language change: trivial, small, medium, big, or huge, and emphasized the fact that each change is also a benefit (hard to measure a priori) that can be estimated as big, medium, or small.&lt;br /&gt;So for example, the new loop syntax introduced in Java5 was a small change with big benefits—a no "brainer", let's do it!&lt;br /&gt; &lt;br /&gt;However, in his talk he showed how "Extended Enums" were at least medium cost with a small benefit.&lt;br /&gt; &lt;br /&gt;I started working on "Extended Enums" (previously "abstract enum") since the release of OpenJDK and the launch of the now defunct KSL (Kitchen Sink Language) in 2006. From the amount of hits this blog is getting on "extended enums", I know this issue is of big concern for many Java developers. &lt;br /&gt;I developed a working solution, but stopped pushing for it for two main reasons:&lt;ul&gt;&lt;li&gt;This addition to the language is a change to the Java-type system. Moreover, it cannot be a small modification; it is at least a medium change.&lt;/li&gt;&lt;li&gt;Looking at Scala Traits or Fantom Mixin, I had the feeling that it was pushing Java too much, and perhaps in the wrong direction.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt; &lt;br /&gt;So I talked with Joe Darcy at Devoxx09 about all the things I discovered implementing this change to the javac compiler (and other needed changes to the JDK classes). It was clear that the change is medium size, but I disagree that the benefits are small. &lt;br /&gt;The benefits of "Extended enums" as implemented today:&lt;ul&gt;&lt;li&gt;Ability for enum declaration to extend an actual abstract class&lt;br /&gt;This is the evident benefit, and it is a small benefit. Using delegation and/or in-lined anonymous classes is not too verbose and provides the same benefits. Still it is nicer and cleaner to have the normal OO inheritance.&lt;/li&gt;&lt;li&gt;Ability to use Generics in Enum classes&lt;br /&gt;With "Extended enums" you can have code like this:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public enum ActionQuery&amp;lt;T extends Action&amp;gt; {&lt;br /&gt;    ALL&amp;lt;Action&amp;gt; {&lt;br /&gt;         public List&amp;lt;Action&amp;gt; getResults() {...}&lt;br /&gt;    },&lt;br /&gt;    EDIT_ACTION&amp;lt;EditAction&amp;gt; {&lt;br /&gt;         public List&amp;lt;EditAction&amp;gt; getResults() {...}&lt;br /&gt;    },&lt;br /&gt;    VIEW_ACTION&amp;lt;ViewAction&amp;gt; {&lt;br /&gt;         public List&amp;lt;ViewAction&amp;gt; getResults() {...}&lt;br /&gt;    };&lt;br /&gt;     public abstract List&amp;lt;T&amp;gt; getResults();&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt; &lt;br /&gt;        I find "Extended enums" very useful in organizing SQL queries and their results, playing with properties and their types, and so on.&lt;/li&gt;&lt;li&gt;The most important feature and the reason why I developed "Extended enums" was to have the ability to define annotation enum parameters without having to specify their list of values in advance. You can already see this issue in today's JPA specification. There is an enum FetchType that is fixed in the spec to LAZY and EAGER, but Hibernate also supports SUBSELECT, which is approximately between LAZY and EAGER. To support SUBSELECT, you need to use the Hibernate specific annotation in combination with the standard one. If the FetchType was an abstract enum, the JPA specification does not need to enforce a well-defined list, but could have a proposed DefaultFetchType and let JPA implementation and application developers define a new enum with their desired list of FetchType. This already works great in the "abstract enum" implementation and provides me with great benefits in many other areas: (such as BindingType in JSR-299 Context and Dependency Injection, Cache declaration using enum instead of error prone string for region, Group in JSR-303 Bean Validation using user defined enums instead of empty interfaces, and more).&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt; &lt;br /&gt;From my point of view (and I think/hope I'm not alone), Joe Darcy missed the benefit point of the extended enum. It is a big benefit to the Java language.&lt;br /&gt;This was and is my position for some time. What pushed me to re-launch "Vote for Extended Enums for the Coin project!", is of course Christof May from &lt;a href="http://soplets.org"&gt;soplets.org&lt;/a&gt; (which setup the extended-enums site: &lt;a href="http://www.extended-enums.org/"&gt;http://www.extended-enums.org/&lt;/a&gt;), and the fact that I found a way to make the change a "small" one. Until now, I was sure that to implement this correctly a new flag was needed in the class byte code, and many changes to the Java type management were necessary.&lt;br /&gt;&lt;br /&gt;So, if you are interested or want to learn more please check the extended enums web site: &lt;a href="http://www.extended-enums.org/"&gt;http://www.extended-enums.org/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-2140059330018711382?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/2140059330018711382/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=2140059330018711382' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/2140059330018711382'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/2140059330018711382'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2011/06/new-push-for-extended-enums.html' title='A new push for extended enums!'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-1591647607330043983</id><published>2009-10-29T16:53:00.009+02:00</published><updated>2009-11-10T17:19:05.678+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='sun'/><category scheme='http://www.blogger.com/atom/ns#' term='ejb3'/><category scheme='http://www.blogger.com/atom/ns#' term='weblogic'/><category scheme='http://www.blogger.com/atom/ns#' term='oracle'/><title type='text'>No singletons allowed in a WebLogic EAR!</title><content type='html'>&lt;h2&gt;The context&lt;/h2&gt;&lt;br /&gt;There is a big EJB3 application (835 Entities, 88 stateless, 1 MDB) that works on JBoss (Server and Embedded) in production with no problem.&lt;br /&gt;We now want to support WebLogic 10.3 and WebSphere 7.0!&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;The problem&lt;/h2&gt;&lt;br /&gt;The application contains "of course" some framework jars to manage cross cutting services (logger, metadata, XML marshalling, ...) using immutable static maps that are initialized at bootstrap time. Nothing extraordinary in my point of view!&lt;br /&gt;Still, we found out that under WebLogic 10.3 the &lt;b&gt;final static&lt;/b&gt; maps are created multiple times!&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;No way!&lt;/h2&gt;&lt;br /&gt;I did not believe it!&lt;br /&gt;I'm working with WebLogic since it was a company (not under BEA), and I always managed and enjoyed creating big enterprise application with it.&lt;br /&gt;Putting JBoss aside (this thread is about WebLogic), in 1999-2002, every presale competition against IBM WebSphere if no politics were involved, WebLogic always won.&lt;br /&gt;From my experience, I always managed to understand the logical behavior of WebLogic, and found a way to deliver the applications to my customers.&lt;br /&gt;Is this crazy behavior due to the influence of Oracle buying BEA almost 2 years ago?&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;The small test case&lt;/h2&gt;&lt;br /&gt;To prove the point, we created a small ejb3 application that can be easily build with Maven 2. Side note: this simple app can be useful to others that wish to test their EJB3 container.&lt;br /&gt;The source code is under subversion &lt;a href="http://subversion.jfrog.org/jfrog/greenhouse/simple-ejb3-app"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;The modules&lt;/h3&gt;&lt;br /&gt;This Enterprise Application has the simplest but complete set of features we need from an EJB3 container. It is made of the following modules (by order of dependency):&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;b&gt;simple-framework&lt;/b&gt;&lt;br/&gt;A simple framework jar that will be part of the EAR and used by the WEB and EJB classes. This module uses only 2 external jars: log4j and slf4j.&lt;/li&gt;&lt;li&gt;&lt;b&gt;another-ejb-sample&lt;/b&gt;&lt;br/&gt;A pure Stateless session bean used from different layer of the other modules to test EJB injection.&lt;/li&gt;&lt;li&gt;&lt;b&gt;ejb-sample&lt;/b&gt;&lt;br/&gt;A simple EJB3 jar with different kind of beans: a Stateful, a Stateless and an Entity. This module contains the persistence.xml that defined the connection to the DB. By default the persistence.xml is configured for a MySQL (the line for Oracle is commented) DB data source with JNDI Name "jdbc/ejb3_ds" which contain one table "customer"&lt;/li&gt;&lt;li&gt;&lt;b&gt;web-sample&lt;/b&gt;&lt;br/&gt;A webapp &lt;a href="http://localhost:7001/web-sample"&gt;http://localhost:7001/web-sample&lt;/a&gt; with a servlet that can activate the different tests.&lt;/li&gt;&lt;li&gt;&lt;b&gt;ear&lt;/b&gt;&lt;br/&gt;A maven module that will create "sample-ejb3-ear.ear" file that can be deployed in WebLogic Server 10.3.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;How to build&lt;/h3&gt;&lt;br /&gt;Use standard maven 2.0.9 or above and run "mvn install" under the root folder of the project. All needed dependencies are coming from &lt;a href="http://hibernate.artifactoryonline.com/"&gt;this repository&lt;/a&gt;.&lt;br/&gt;&lt;br /&gt;After a successful build the "ear/target/sample-ejb3-ear.ear" can be deployed on a correctly configured WebLogic 10.3 Server.&lt;br /&gt;&lt;h4&gt;WebLogic and DB configuration&lt;/h4&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;For MySQL:&lt;pre&gt;create table customer (&lt;br /&gt; id int(10) unsigned not null auto_increment,&lt;br /&gt; name varchar(255) default null,&lt;br /&gt; primary key (id));&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;For Oracle:&lt;pre&gt;create table customer (&lt;br /&gt; ID NUMBER(12,0) NOT NULL ENABLE,&lt;br /&gt; NAME VARCHAR2(200),&lt;br /&gt; CONSTRAINT CUSTOMER PRIMARY KEY (ID) USING INDEX COMPUTE STATISTICS);&lt;br /&gt;&lt;br /&gt; create sequence CORE.hibernate_sequence&lt;br /&gt; start with 1 increment by 1 nomaxvalue;&lt;/pre&gt;&lt;li&gt;Need to create a data source with JNDI Name "jdbc/ejb3_ds" for the DB.&lt;/li&gt;&lt;li&gt;Deploy the "sample-ejb3-ear.ear" application in WLS 10.3.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;The Results&lt;/h2&gt;&lt;br /&gt;You will see in the log that a pure and simple singleton LogServiceImpl available in the "simple-framework" module is initialized 3 times (which is 2 times too much for a singleton :). The 3 times match the 3 beans (2 stateless, 1 entity) where the standard log variables appears &lt;pre&gt;private static final Log log = LogService.getLog(...);&lt;/pre&gt;&lt;br /&gt;Any solution to solve this problem will be extremely painful, since basically ALL our static members are not static anymore. Any solution will have to be based on a ThreadLocal entry hoping that one single thread is doing the code analysis :).&lt;br /&gt;What's even more worrying for us, is that these classes loaded with different class loader (static stack), are not discarded after code analysis, but assembled together!&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Possible Solutions?&lt;/h3&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;We added a &amp;lt;classloader-structure&gt; in the weblogic-application.xml file to enforce a single class loader for the whole EAR, it still in the code and did not work.&lt;/li&gt;&lt;li&gt;We tested with Sun JVM 1.6 and JRockit. Both gave the same results&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;b&gt;Are we missing a flag "unified class loader for EAR"?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Who is doing what?&lt;/h3&gt;&lt;br /&gt;Here is the full stack of &lt;b&gt;3 different creations of the same singleton&lt;/b&gt;. It's hard to write something like this after 12 years of Java development :( :&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;[04-11-09 14:52:18.867] INFO  SessionFactoryImpl - building session factory&lt;br /&gt;java.lang.Exception: THIS SHOULD HAPPEN ONLY ONCE&lt;br /&gt; at greenhouse.ejb3.sample.framework.LogServiceImpl.&amp;lt;init&gt;(LogServiceImpl.java:54)&lt;br /&gt; at greenhouse.ejb3.sample.framework.LogServiceImpl.&amp;lt;clinit&gt;(LogServiceImpl.java:51)&lt;br /&gt; at greenhouse.ejb3.sample.framework.LogService.getLog(LogService.java:23)&lt;br /&gt; at greenhouse.ejb3.sample.Customer.&amp;lt;clinit&gt;(Customer.java:35)&lt;br /&gt; at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)&lt;br /&gt; at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)&lt;br /&gt; at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)&lt;br /&gt; at java.lang.reflect.Constructor.newInstance(Constructor.java:513)&lt;br /&gt; at org.hibernate.engine.UnsavedValueFactory.instantiate(UnsavedValueFactory.java:22)&lt;br /&gt; at org.hibernate.engine.UnsavedValueFactory.getUnsavedIdentifierValue(UnsavedValueFactory.java:44)&lt;br /&gt; at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:44)&lt;br /&gt; at org.hibernate.tuple.entity.EntityMetamodel.&amp;lt;init&gt;(EntityMetamodel.java:124)&lt;br /&gt; at org.hibernate.persister.entity.AbstractEntityPersister.&amp;lt;init&gt;(AbstractEntityPersister.java:434)&lt;br /&gt; at org.hibernate.persister.entity.SingleTableEntityPersister.&amp;lt;init&gt;(SingleTableEntityPersister.java:109)&lt;br /&gt; at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)&lt;br /&gt; at org.hibernate.impl.SessionFactoryImpl.&amp;lt;init&gt;(SessionFactoryImpl.java:226)&lt;br /&gt; at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)&lt;br /&gt; at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)&lt;br /&gt; at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)&lt;br /&gt; at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:132)&lt;br /&gt; at weblogic.deployment.PersistenceUnitInfoImpl.createEntityManagerFactory(PersistenceUnitInfoImpl.java:330)&lt;br /&gt; at weblogic.deployment.PersistenceUnitInfoImpl.&amp;lt;init&gt;(PersistenceUnitInfoImpl.java:123)&lt;br /&gt; at weblogic.deployment.AbstractPersistenceUnitRegistry.storeDescriptors(AbstractPersistenceUnitRegistry.java:331)&lt;br /&gt; at weblogic.deployment.AbstractPersistenceUnitRegistry.loadPersistenceDescriptor(AbstractPersistenceUnitRegistry.java:245)&lt;br /&gt; at weblogic.deployment.ModulePersistenceUnitRegistry.&amp;lt;init&gt;(ModulePersistenceUnitRegistry.java:63)&lt;br /&gt; at weblogic.ejb.container.deployer.EJBModule.setupPersistenceUnitRegistry(EJBModule.java:209)&lt;br /&gt; at weblogic.ejb.container.deployer.EJBModule$1.execute(EJBModule.java:310)&lt;br /&gt; at weblogic.deployment.PersistenceUnitRegistryInitializer.setupPersistenceUnitRegistries(PersistenceUnitRegistryInitializer.java:62)&lt;br /&gt; at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:376)&lt;br /&gt; at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)&lt;br /&gt; at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:387)&lt;br /&gt; at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)&lt;br /&gt; at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:58)&lt;br /&gt; at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:42)&lt;br /&gt; at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:615)&lt;br /&gt; at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)&lt;br /&gt; at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191)&lt;br /&gt; at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:16)&lt;br /&gt; at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:155)&lt;br /&gt; at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)&lt;br /&gt; at weblogic.deploy.internal.targetserver.AppDeployment.prepare(AppDeployment.java:141)&lt;br /&gt; at weblogic.management.deploy.internal.DeploymentAdapter$1.doPrepare(DeploymentAdapter.java:39)&lt;br /&gt; at weblogic.management.deploy.internal.DeploymentAdapter.prepare(DeploymentAdapter.java:187)&lt;br /&gt; at weblogic.management.deploy.internal.AppTransition$1.transitionApp(AppTransition.java:21)&lt;br /&gt; at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:233)&lt;br /&gt; at weblogic.management.deploy.internal.ConfiguredDeployments.prepare(ConfiguredDeployments.java:165)&lt;br /&gt; at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:122)&lt;br /&gt; at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:173)&lt;br /&gt; at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:89)&lt;br /&gt; at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)&lt;br /&gt; at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)&lt;br /&gt; at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)&lt;br /&gt;[04-11-09 14:52:19.117] INFO  Customer - A new customer is created&lt;br /&gt;[04-11-09 14:52:19.492] INFO  SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured&lt;br /&gt;[04-11-09 14:52:19.495] INFO  NamingHelper - JNDI InitialContext properties:{}&lt;br /&gt;java.lang.Exception: THIS SHOULD HAPPEN ONLY ONCE&lt;br /&gt; at greenhouse.ejb3.sample.framework.LogServiceImpl.&amp;lt;init&gt;(LogServiceImpl.java:54)&lt;br /&gt; at greenhouse.ejb3.sample.framework.LogServiceImpl.&amp;lt;clinit&gt;(LogServiceImpl.java:51)&lt;br /&gt; at greenhouse.ejb3.sample.framework.LogService.getLog(LogService.java:23)&lt;br /&gt; at greenhouse.ejb3.sample.CustomerDAOBean.&amp;lt;clinit&gt;(CustomerDAOBean.java:26)&lt;br /&gt; at java.lang.Class.forName0(Native Method)&lt;br /&gt; at java.lang.Class.forName(Class.java:247)&lt;br /&gt; at weblogic.j2ee.dd.xml.validator.AnnotationValidatorHelper.getClass(AnnotationValidatorHelper.java:14)&lt;br /&gt; at weblogic.j2ee.dd.xml.validator.injectiontarget.BaseValidator.getClass(BaseValidator.java:38)&lt;br /&gt; at weblogic.j2ee.dd.xml.validator.AbstractAnnotationValidator.validate(AbstractAnnotationValidator.java:22)&lt;br /&gt; at weblogic.j2ee.dd.xml.validator.AnnotationValidatorVisitor.visitInjectionTargetBean(AnnotationValidatorVisitor.java:48)&lt;br /&gt; at weblogic.j2ee.dd.xml.validator.AnnotationValidatorVisitor.visit(AnnotationValidatorVisitor.java:25)&lt;br /&gt; at weblogic.descriptor.internal.AbstractDescriptorBean.accept(AbstractDescriptorBean.java:1124)&lt;br /&gt; at weblogic.descriptor.internal.AbstractDescriptorBean.accept(AbstractDescriptorBean.java:1128)&lt;br /&gt; at weblogic.descriptor.internal.AbstractDescriptorBean.accept(AbstractDescriptorBean.java:1128)&lt;br /&gt; at weblogic.descriptor.internal.AbstractDescriptorBean.accept(AbstractDescriptorBean.java:1128)&lt;br /&gt; at weblogic.descriptor.internal.AbstractDescriptorBean.accept(AbstractDescriptorBean.java:1128)&lt;br /&gt; at weblogic.j2ee.dd.xml.BaseJ2eeAnnotationProcessor.validate(BaseJ2eeAnnotationProcessor.java:143)&lt;br /&gt; at weblogic.j2ee.dd.xml.BaseJ2eeAnnotationProcessor.validate(BaseJ2eeAnnotationProcessor.java:131)&lt;br /&gt; at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processAnnotations(EjbAnnotationProcessor.java:205)&lt;br /&gt; at weblogic.ejb.container.dd.xml.EjbDescriptorReaderImpl.processStandardAnnotations(EjbDescriptorReaderImpl.java:324)&lt;br /&gt; at weblogic.ejb.container.dd.xml.EjbDescriptorReaderImpl.createReadOnlyDescriptorFromJarFile(EjbDescriptorReaderImpl.java:190)&lt;br /&gt; at weblogic.ejb.spi.EjbDescriptorFactory.createReadOnlyDescriptorFromJarFile(EjbDescriptorFactory.java:93)&lt;br /&gt; at weblogic.ejb.container.deployer.EJBModule.loadEJBDescriptor(EJBModule.java:1198)&lt;br /&gt; at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:380)&lt;br /&gt; at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)&lt;br /&gt; at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:387)&lt;br /&gt; at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)&lt;br /&gt; at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:58)&lt;br /&gt; at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:42)&lt;br /&gt; at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:615)&lt;br /&gt; at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)&lt;br /&gt; at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191)&lt;br /&gt; at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:16)&lt;br /&gt; at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:155)&lt;br /&gt; at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)&lt;br /&gt; at weblogic.deploy.internal.targetserver.AppDeployment.prepare(AppDeployment.java:141)&lt;br /&gt; at weblogic.management.deploy.internal.DeploymentAdapter$1.doPrepare(DeploymentAdapter.java:39)&lt;br /&gt; at weblogic.management.deploy.internal.DeploymentAdapter.prepare(DeploymentAdapter.java:187)&lt;br /&gt; at weblogic.management.deploy.internal.AppTransition$1.transitionApp(AppTransition.java:21)&lt;br /&gt; at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:233)&lt;br /&gt; at weblogic.management.deploy.internal.ConfiguredDeployments.prepare(ConfiguredDeployments.java:165)&lt;br /&gt; at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:122)&lt;br /&gt; at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:173)&lt;br /&gt; at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:89)&lt;br /&gt; at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)&lt;br /&gt; at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)&lt;br /&gt; at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)&lt;br /&gt;java.lang.Exception: THIS SHOULD HAPPEN ONLY ONCE&lt;br /&gt; at greenhouse.ejb3.sample.framework.LogServiceImpl.&amp;lt;init&gt;(LogServiceImpl.java:54)&lt;br /&gt; at greenhouse.ejb3.sample.framework.LogServiceImpl.&amp;lt;clinit&gt;(LogServiceImpl.java:51)&lt;br /&gt; at greenhouse.ejb3.sample.framework.LogService.getLog(LogService.java:23)&lt;br /&gt; at greenhouse.ejb3.sample.RandomNumberGeneratorBean.&amp;lt;clinit&gt;(RandomNumberGeneratorBean.java:16)&lt;br /&gt; at java.lang.Class.forName0(Native Method)&lt;br /&gt; at java.lang.Class.forName(Class.java:247)&lt;br /&gt; at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processWLSAnnotations(EjbAnnotationProcessor.java:1699)&lt;br /&gt; at weblogic.ejb.container.dd.xml.EjbDescriptorReaderImpl.processWLSAnnotations(EjbDescriptorReaderImpl.java:346)&lt;br /&gt; at weblogic.ejb.container.dd.xml.EjbDescriptorReaderImpl.createReadOnlyDescriptorFromJarFile(EjbDescriptorReaderImpl.java:192)&lt;br /&gt; at weblogic.ejb.spi.EjbDescriptorFactory.createReadOnlyDescriptorFromJarFile(EjbDescriptorFactory.java:93)&lt;br /&gt; at weblogic.ejb.container.deployer.EJBModule.loadEJBDescriptor(EJBModule.java:1198)&lt;br /&gt; at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:380)&lt;br /&gt; at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)&lt;br /&gt; at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:387)&lt;br /&gt; at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)&lt;br /&gt; at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:58)&lt;br /&gt; at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:42)&lt;br /&gt; at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:615)&lt;br /&gt; at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)&lt;br /&gt; at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191)&lt;br /&gt; at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:16)&lt;br /&gt; at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:155)&lt;br /&gt; at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)&lt;br /&gt; at weblogic.deploy.internal.targetserver.AppDeployment.prepare(AppDeployment.java:141)&lt;br /&gt; at weblogic.management.deploy.internal.DeploymentAdapter$1.doPrepare(DeploymentAdapter.java:39)&lt;br /&gt; at weblogic.management.deploy.internal.DeploymentAdapter.prepare(DeploymentAdapter.java:187)&lt;br /&gt; at weblogic.management.deploy.internal.AppTransition$1.transitionApp(AppTransition.java:21)&lt;br /&gt; at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:233)&lt;br /&gt; at weblogic.management.deploy.internal.ConfiguredDeployments.prepare(ConfiguredDeployments.java:165)&lt;br /&gt; at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:122)&lt;br /&gt; at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:173)&lt;br /&gt; at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:89)&lt;br /&gt; at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)&lt;br /&gt; at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)&lt;br /&gt; at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Update on Nov 10th 2009&lt;/h3&gt;&lt;br /&gt;Thanks to &lt;a href="http://drorbr.blogspot.com/"&gt;Dror Bereznetsky&lt;/a&gt; for the heads up on  the code analysis of &lt;i&gt;"EjbDescriptorReaderImpl.createReadOnlyDescriptorFromJarFile(EjbDescriptorReaderImpl.java:192)"&lt;/i&gt; I managed to create a small patch to weblogic.jar that solved the problem.&lt;br/&gt;&lt;br /&gt;The &lt;b&gt;"stupid"&lt;/b&gt; issue is that the new class loader created for bean analysis was using the parent class loader of the EAR classloader, basically ignoring all the classes of my application that where reloaded on each analysis...&lt;br/&gt;&lt;br /&gt;I went very strong on my patch making the parent of the bean analyzer class loader the current thread class loader, and it works. More tests coming, and a small hope that "Oracle" will solve the bug soon :(&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-1591647607330043983?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/1591647607330043983/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=1591647607330043983' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/1591647607330043983'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/1591647607330043983'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2009/10/no-singletons-allowed-in-weblogic-ear.html' title='No singletons allowed in a WebLogic EAR!'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-3383380920184435312</id><published>2009-09-11T00:15:00.005+03:00</published><updated>2009-09-11T00:58:22.219+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='macos'/><category scheme='http://www.blogger.com/atom/ns#' term='java6'/><title type='text'>Java6 and IntelliJ on MacOS X</title><content type='html'>It's the third time now that I'm going through this, and each time I'm forgetting something...&lt;br /&gt;&lt;br /&gt;The main problems I'm having are:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;How to enforce Java6 64bit JVM as the default on MacOS?&lt;/li&gt;&lt;br /&gt;&lt;li&gt;How to make IntelliJ use it?&lt;/li&gt;&lt;br /&gt;&lt;li&gt;How to make Safari (and may be one day Firefox) use it&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;I know I'm loosing SWT, and many soft (like NetBeans and IntelliJ) enforce Java 5 has hard coded default on the Mac, but I'm developing in &lt;a href="http://fandev.org/"&gt;Fan&lt;/a&gt; and the &lt;a href="http://wiki.jfrog.org/confluence/display/FANP/Home"&gt;IntelliJ Fan Plugin&lt;/a&gt;, and Java 6 is kind of a must :)&lt;br /&gt;&lt;br /&gt;So, here is what I do:&lt;br /&gt;&lt;b&gt;On each update of Java6 from Apple&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;As root I go under:&lt;br /&gt;&lt;span style="font-family: courier new;font-size:12px"&gt;cd /System/Library/Frameworks/JavaVM.framework/Versions/&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;There should be a symlink: CurrentJDK -&gt; 1.5&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Then I change the link:&lt;br /&gt;&lt;span style="font-family: courier new;font-size:12px"&gt;rm CurrentJDK &amp;amp;&amp;amp; ln -s 1.6 CurrentJDK&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;On each update of IntelliJ&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Download the idea-XXX.dmg, the idea-XXX.tar.gz (64 bit not the jdk15 version), and idea-XXX-dev.zip. I hope JetBrains will start giving dmg files for the 64 bit JVM, because it's big downloads :(&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Copy the "IntelliJ IDEA XXX.app" folder from DMG to Applications. I have /Applications/IntelliJ and /Applications/NetBeans with the versions I used, it helps when I'm messing up :)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Do a copy of it under "IntelliJ IDEA XXX-jdk15.app" for backup and to be able to compile IntelliJ plugin for 1.5&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Extract the idea-XXX.tar.gz under /Applications/IntelliJ&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Copy all the jar files from idea-XXX to "IntelliJ IDEA XXX.app". I do as root under idea-XXX:&lt;br /&gt;&lt;span style="font-family: courier new;font-size:12px"&gt;find . -name "*.jar" -exec cp \{\} ../IntelliJ\ IDEA\ XXX.app/\{\} \;&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the "IntelliJ IDEA XXX.app/Contents/Info.plist" with:&lt;span style="font-family: courier new;font-size:12px"&gt;&lt;br /&gt;     &amp;lt;key&gt;JVMVersion&amp;lt;/key&gt;&lt;br /&gt;     &amp;lt;string&gt;1.6*&amp;lt;/string&gt;&lt;br /&gt;&lt;br /&gt;     &amp;lt;key&gt;VMOptions&amp;lt;/key&gt;&lt;br /&gt;     &amp;lt;string&gt;-Xms400m -Xmx1248m -XX:MaxPermSize=192m -XX:PermSize=192m -Xbootclasspath/a:../lib/boot.jar -ea&amp;lt;/string&gt;&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Here usually I try to run "open /Applications/IntelliJ IDEA XXX.app" and I get:&lt;br /&gt;&lt;span style="font-family: courier new;font-size:12px"&gt;LSOpenFromURLSpec() failed with error -10810 for the file /Applications/IntelliJ/IntelliJ IDEA XXX.app&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;The the solution is (as root):&lt;br /&gt;&lt;span style="font-family: courier new;font-size:12px"&gt;cp /System/Library/Frameworks/JavaVM.framework/Resources/MacOS/JavaApplicationStub64 /Applications/IntelliJ/IntelliJ\ IDEA\ XXX.app/Contents/MacOS/idea&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;For Safari and Firefox, I still don't manage to do it!&lt;br /&gt;&lt;br /&gt;Hope I won't have to do this too much in the future, once everyone agrees on JDK 1.6 64 bits as Mac OS X default.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-3383380920184435312?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/3383380920184435312/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=3383380920184435312' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/3383380920184435312'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/3383380920184435312'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2009/09/java6-and-intellij-on-macos-x.html' title='Java6 and IntelliJ on MacOS X'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-7678176487068222469</id><published>2009-05-11T23:09:00.002+03:00</published><updated>2009-05-11T23:12:23.505+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='javaone'/><category scheme='http://www.blogger.com/atom/ns#' term='UI'/><title type='text'>Maven and JavaFX, the story of TwitterFX POM</title><content type='html'>I posted on the JFrog's mouth our story of &lt;a href="http://blogs.jfrog.org/2009/05/maven-and-javafx-story-of-twitterfx-pom.html"&gt;migrating TwitterFX&lt;/a&gt; codebase to Maven.&lt;br /&gt;We had fun, and we'll show it all at JavaOne.&lt;br /&gt;&lt;a href="http://java.sun.com/javaone" target="_blank"&gt;&lt;img src="http://www.cplan.com/javaone2009/creativetoolbox/images/09J1_200x200_Speaker_Button_Duke.gif" alt="I'm Speaking At JavaOne" width="200" height="200" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-7678176487068222469?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/7678176487068222469/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=7678176487068222469' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/7678176487068222469'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/7678176487068222469'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2009/05/maven-and-javafx-story-of-twitterfx-pom.html' title='Maven and JavaFX, the story of TwitterFX POM'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-7232610849791701339</id><published>2008-12-30T10:56:00.001+02:00</published><updated>2008-12-30T11:17:40.724+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wild'/><title type='text'>Why natural selection did not kill the scientists?</title><content type='html'>A new post on Nothing is Infinite seems good for software techies too :)&lt;br /&gt;&lt;a href="http://nothingisinfinite.blogspot.com/2008/12/why-natural-selection-did-not-kill.html"&gt;Why natural selection did not kill the scientists?&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-7232610849791701339?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/7232610849791701339/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=7232610849791701339' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/7232610849791701339'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/7232610849791701339'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2008/12/why-natural-selection-did-not-kill.html' title='Why natural selection did not kill the scientists?'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-781201644846605980</id><published>2008-11-22T13:32:00.000+02:00</published><updated>2008-11-22T13:41:38.537+02:00</updated><title type='text'>Obama from a 9 year old!</title><content type='html'>Being a French man living in Israel, we have 3 languages at home: English, French and Hebrew.&lt;br /&gt;And many of my friends around here have this trilingual environment.&lt;br /&gt;Last week the 9 year old son of one of them told him:&lt;br /&gt;- Dad, Obama is talking Hebrew?&lt;br /&gt;- No, Why do you ask?&lt;br /&gt;- Because he keep saying: Yes Oui Ken!&lt;br /&gt;&lt;br /&gt;Note: "Yes We Can" sounds like Yes, Oui (yes in French), Ken (yes in Hebrew).&lt;br /&gt;&lt;br /&gt;Amazing no?&lt;br /&gt;I found out that it was &lt;a href="http://frgdr.com/blog/2008/07/22/obama-hebrew-poster-oui-ken/"&gt;already used&lt;/a&gt; in Obama's campaign.&lt;br /&gt;&lt;br /&gt;Anyway, international triple yes from an Israeli 9 year old kid...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-781201644846605980?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/781201644846605980/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=781201644846605980' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/781201644846605980'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/781201644846605980'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2008/11/obama-from-9-year-old.html' title='Obama from a 9 year old!'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-2596663427292253148</id><published>2008-11-20T14:36:00.001+02:00</published><updated>2008-11-20T15:28:04.451+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='UI'/><category scheme='http://www.blogger.com/atom/ns#' term='artifactory'/><title type='text'>Lists and Contextual Menus, MMI nightmare!</title><content type='html'>I'm more of a "server side" kind of developer.&lt;br /&gt;When I see too much HTML, CSS and Javascript, I need pills!&lt;br /&gt;Still, I like to challenge the MVC architecture of UI frameworks. I even wrote my own web framework for fun (but some poor developers, in India I think, are now suffering from it), and played with Swing developing Stellarium4Java.&lt;br /&gt;&lt;br /&gt;So, UI is not my cup of Tea. Now, for the latest release of &lt;a href="http://artifactory.jfrog.org/"&gt;Artifactory&lt;/a&gt;, I needed to managed the communication between the UI Designer and the Web developers. I learned a lot from this interesting experience.&lt;br /&gt;During this process I encountered a really basic UI design issue. It was so basic I got worried I missed something!&lt;br /&gt;The point is: The way we are used to manage lists, selections, actions and contextual menus is totally incoherent.&lt;br /&gt;&lt;br /&gt;In real UI applications (fat client and Ajax), you get a list of elements and then you can act on them. Usually, you select a line, then some Action (Buttons, Menus) become enabled and you can activate them. But to minimize the amount of clicks and mouse gestures there are also contextual menus. This is where it gets weird...&lt;br /&gt;You select one line, and then can actually "right click" on another one. That way, the list of Actions on the contextual menus does not match the one in buttons and menus.&lt;br /&gt;You can force select the line where you right click, but few Applications are doing it!&lt;br /&gt;&lt;br /&gt;The other issue is that contextual menus are really not that great (i.e. I hate them!):&lt;br /&gt;&lt;ul&gt;&lt;li&gt;They are not Web Browser friendly.&lt;/li&gt;&lt;li&gt;They don't actually save much in terms of clicks and gestures (right click, move, left click).&lt;/li&gt;&lt;li&gt;They get in the middle of reading the lists of elements.&lt;/li&gt;&lt;li&gt;They never disappear when you want them to, and always disappear before you find the menu item you want to click on.&lt;/li&gt;&lt;li&gt;To remove them go away you need to click elsewhere, crossing your finger you did not actually click on "buy in one click" button.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;One solution on the Web (and on the iPhone/iPod, where there is no right click :), is to add action buttons directly in the list itself as columns. That works and can be nice looking (with good icons) but this technique get very heavy (bunch of garbage icons all over). Anyway, it is not scalable: 5 icons it's already too much.&lt;br /&gt;&lt;br /&gt;So, the UI designer came with the really cool idea: A hovering toolbox appearing on the side of the list when rollover the line element.&lt;br /&gt;At first, I thought:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;It may work but we'd be going against a big UI muscle memory about how to use a list.&lt;/li&gt;&lt;li&gt;People will hate it!&lt;/li&gt;&lt;li&gt;The toolbox is too far from where my mouse is, and going there will be very annoying.&lt;/li&gt;&lt;li&gt;We are not here to reinvent UI and Men Machine Interaction!&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;But, anyway I took the chance and we implemented it. To see it, you can go to &lt;a href="http://repo.jfrog.org/artifactory/"&gt;Artifactory live demo&lt;/a&gt;, do a quick search on "log" for example, and hover above the list. It's still a beta version and the previous select/link actions are not removed, so it may be confusing. As anonymous user your action list is limited, but you can still get the feel of it.&lt;br /&gt;&lt;br /&gt;I'm using this feature for 2 weeks now and frankly: I love it!&lt;br /&gt;I hover on the list in the left side of it, I can read the line I'm on, and then activate the action with one click. Just natural moves and ONLY ONE click.&lt;br /&gt;&lt;br /&gt;May be I'm under the influence (it's our application at the end :), and that's why I'm anxiously waiting for the feedback!&lt;br /&gt;What do you think?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-2596663427292253148?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/2596663427292253148/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=2596663427292253148' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/2596663427292253148'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/2596663427292253148'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2008/11/lists-and-contextual-menus-mmi.html' title='Lists and Contextual Menus, MMI nightmare!'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-7284789385465639131</id><published>2008-10-30T16:19:00.001+02:00</published><updated>2008-10-30T19:12:23.007+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='financial crisis'/><category scheme='http://www.blogger.com/atom/ns#' term='architecture'/><title type='text'>IT opportunities in the current financial crisis?</title><content type='html'>I'm not optimistic, but here is a fact: For more than 20 years (since the 1987 crash) or in some cases since the usage of computers in companies, the IT budgets of financial institutions (banks, insurance companies, stock markets etc.) ALWAYS go up.&lt;br /&gt;In the meantime, technologies went from Mainframe, to Client/Server, to Web 1.0, to Web 2.0, to SOA, to Virtualization and now Cloud Computing. But in spite of all the technological advances, IT budgets ALWAYS go up. I've given consulting services to many banks and insurance companies, and one thing got increasingly clear: If you're trying to sell a software that will reduce their IT budget... Forget it! &lt;p style="margin-bottom: 0in;" align="left"&gt;&lt;br /&gt;Of course, the financial institutions' needs from IT increased in the last 20 years. They want to setup new services and products (online banking, new policies, new mortgages :) faster than their competitors. But the increase in end user demands is an order of magnitude lower than the technological advances in hardware and software. IT budgets should have gone down, and insurance premiums and bank fees also. But no - IT budgets ALWAYS go up.&lt;/p&gt; &lt;p style="margin-bottom: 0in;" align="left"&gt;&lt;br /&gt;I think the main reason is Wall Street. If you are Bank of America, and someone finds out you're reducing your IT budget... Your stock will go down immediately!&lt;/p&gt;&lt;div class="Ih2E3d"&gt;&lt;br /&gt;A month ago after 20 years of IT budget increases all the CIO and IT department in financial companies have a huge amount of cash fat.&lt;br /&gt;Where the fat goes?&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Buying hard to install and unmaintainable software (you need to keep all these engineers) from BIG vendors.&lt;/li&gt;&lt;li&gt;Buying low performance hardware for incredible amounts of money.&lt;/li&gt;&lt;li&gt;Of course, a big team of developers and system engineers to oil down the cranky machines.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class="Ih2E3d"&gt;&lt;br /&gt;And now, for the first time all the CIOs have only one goal: Reduce your IT budget!&lt;br /&gt;IT department in financial companies will never be the same!&lt;br /&gt;&lt;br /&gt;From my knowledge, and experience with theses companies their IT budget is about 3 to 5 times bigger than it should be. I don't think they will go all the way and slash 80% of the IT department, but what's for sure, they'll slash the vendors, and contractors.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;I think one big software/hardware company will suffer big time from this change because it's living and breathing of this fat. The saying was that a CIO choosing IBM will never get fired for his choice (even he wasted time and money on a failed project). Today that thinking changed.&lt;div class="Ih2E3d"&gt;&lt;br /&gt;So, where are the opportunities?&lt;br /&gt;Well, now you can really sell and prove the advantages of modern technological advances to financial CIO. They will be sensitive to TCO, developer productivity, software quality and maintenance.&lt;br /&gt;&lt;/div&gt;The issue is that no CIO will start a costly migration project now! So the current state of IT will be frozen for some time. But, some companies will really analyze what's going on and make a decision to go with open source, agile and distributed all the way.&lt;br /&gt;&lt;br /&gt;Things will change in banks and insurance companies IT departments, let's hope WebsFear does not blackmail their customers again...&lt;br /&gt;&lt;br /&gt;Originally posted on &lt;a href="http://java.dzone.com/articles/it-opportunities-current-finan"&gt;dzone&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-7284789385465639131?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/7284789385465639131/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=7284789385465639131' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/7284789385465639131'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/7284789385465639131'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2008/10/it-opportunities-in-current-financial.html' title='IT opportunities in the current financial crisis?'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-4748628342383448512</id><published>2008-09-10T11:41:00.000+03:00</published><updated>2008-09-10T12:09:09.262+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><title type='text'>All new?</title><content type='html'>The amount of new Web adventures going on around me starts to make a big pile. So, instead of twittering them with 144 characters, here they are:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;A very good content Podcast about Java on server side from AlphaCSP consultants: &lt;a href="http://alphacsp.libsyn.com/"&gt;The Alpha Pub&lt;/a&gt;. I really enjoyed the show, and the latest interview with &lt;a href="http://blog.springsource.com/main/author/alefa/"&gt;Alef Arendsen&lt;/a&gt; has very good content. Thanks, Ophir for setting up this!&lt;/li&gt;&lt;li&gt;The &lt;a href="http://www.alphacsp.com/Events/JavaEdge-2008/JavaEdge-2008.htm"&gt;JavaEdge 2008&lt;/a&gt; is on the way, and it's going to be even better than last year!&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.jfrog.org/"&gt;JFrog.org&lt;/a&gt; just released the version &lt;a href="http://www.nabble.com/-ANN--Artifactory-1.3.0-beta-3-td19368349.html"&gt;1.3.0-beta-3&lt;/a&gt; of &lt;a href="http://www.jfrog.org/sites/artifactory/latest/"&gt;Artifactory&lt;/a&gt; with the &lt;a href="http://freddy33.blogspot.com/2008/07/using-jersey-for-exposing-rest-services.html"&gt;integration of Jersey&lt;/a&gt;, which was a lot of fun to do.&lt;/li&gt;&lt;li&gt;I sarted a &lt;a href="http://nothingisinfinite.blogspot.com/"&gt;new blog&lt;/a&gt; to release in the wild my toughts around Space, Physics and the &lt;a href="http://www.math.columbia.edu/%7Ewoit/wordpress/"&gt;bad taste&lt;/a&gt; left by the &lt;a href="http://www.thetroublewithphysics.com/"&gt;failure&lt;/a&gt; of Super String Theory!&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;That's a lot of good stuff coming, and I'm really missing &lt;a href="http://stellarium4java.sourceforge.net/"&gt;Stellarium4Java&lt;/a&gt; and &lt;a href="http://openjdk.java.net/"&gt;OpenJDK&lt;/a&gt;, but that's life... Need to set priorities, and be happy about what you did not do!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-4748628342383448512?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/4748628342383448512/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=4748628342383448512' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/4748628342383448512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/4748628342383448512'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2008/09/all-new.html' title='All new?'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-8955220872826436763</id><published>2008-07-30T11:21:00.006+03:00</published><updated>2008-09-03T17:40:32.954+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='rest'/><category scheme='http://www.blogger.com/atom/ns#' term='sun'/><category scheme='http://www.blogger.com/atom/ns#' term='webbeans'/><category scheme='http://www.blogger.com/atom/ns#' term='jersey'/><category scheme='http://www.blogger.com/atom/ns#' term='artifactory'/><title type='text'>Using Jersey for exposing REST services</title><content type='html'>I just started integrating &lt;a href="https://jersey.dev.java.net/servlets/ProjectDocumentList?folderID=7653&amp;amp;expandFolder=7653&amp;amp;folderID=0"&gt;Jersey&lt;/a&gt; in &lt;a href="http://www.jfrog.org/sites/artifactory/latest/"&gt;Artifactory&lt;/a&gt; and I have to say: I'm impressed!&lt;br /&gt;Like the XFire (still crying on its death :( ) I really like the process of: Write a simple annotated POJO, compile and run, that's it.&lt;br /&gt;&lt;br /&gt;Anyway, since I encountered a couple of issues, and implemented some nice extra (XStream adapter and Spring beans injection) here are my findings.&lt;br /&gt;First thanks to &lt;a href="http://blog.spaceprogram.com/2008/01/getting-started-with-jax-rs-and-jersey.html"&gt;getting started entry&lt;/a&gt; and &lt;a href="https://jersey.dev.java.net/use/getting-started.html"&gt;getting started with jersey&lt;/a&gt; that convinced me Jersey is the way to go.&lt;br /&gt;&lt;h4&gt;Getting started&lt;/h4&gt;&lt;br /&gt;I'm using Maven and Jetty and so running the HelloWorld example got this &lt;a href="https://jersey.dev.java.net/issues/show_bug.cgi?id=70"&gt;bug 70&lt;/a&gt;. Setting up the Annotation scanner per Java packages solves the problem, and anyway sounds a lot more manageable to me. So here is my web.xml (for 0.8):&lt;br /&gt;&lt;pre style="line-height: 100%;font-family:courier new;font-size:80%;background-color:#ffffff; border-width:0.01mm; border-color:#000000; border-style:solid; padding:4px;"&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;servlet&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;    &lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;servlet-name&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;font-weight:bold;"&gt;Jersey&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="background-color:#ffffff;font-weight:bold;"&gt;Web&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="background-color:#ffffff;font-weight:bold;"&gt;Application&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;servlet-name&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;    &lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;servlet-class&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;font-weight:bold;"&gt;org.artifactory.rest.servlet.ArtifactoryRestServlet&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;servlet-class&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;    &lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;init-param&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;        &lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;param-name&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;font-weight:bold;"&gt;com.sun.jersey.config.property.resourceConfigClass&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;param-name&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;        &lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;param-value&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;font-weight:bold;"&gt;com.sun.jersey.api.core.PackagesResourceConfig&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;param-value&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;    &lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;init-param&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;    &lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;init-param&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;        &lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;param-name&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;font-weight:bold;"&gt;com.sun.jersey.config.property.packages&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;param-name&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;        &lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;param-value&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;font-weight:bold;"&gt;org.artifactory.rest&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;param-value&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;    &lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;init-param&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;    &lt;/span&gt;&lt;span style="color:#808080;background-color:#ffffff;font-style:italic;"&gt;&amp;lt;!-- Usable only in 0.9 version of Jersey&lt;br /&gt;    &amp;lt;init-param&amp;gt;&lt;br /&gt;        &amp;lt;param-name&amp;gt;com.sun.jersey.spi.container.ContainerRequestFilters&amp;lt;/param-name&amp;gt;&lt;br /&gt;        &amp;lt;param-value&amp;gt;org.artifactory.rest.common.AuthorizationContainerRequestFilter&amp;lt;/param-value&amp;gt;&lt;br /&gt;    &amp;lt;/init-param&amp;gt;&lt;br /&gt;    --&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;    &lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;load-on-startup&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;font-weight:bold;"&gt;1&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;load-on-startup&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;servlet&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;servlet-mapping&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;    &lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;servlet-name&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;font-weight:bold;"&gt;Jersey&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="background-color:#ffffff;font-weight:bold;"&gt;Web&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="background-color:#ffffff;font-weight:bold;"&gt;Application&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;servlet-name&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;    &lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;url-pattern&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;font-weight:bold;"&gt;/api/*&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;url-pattern&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;servlet-mapping&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;So now the annotations scanner reads correctly my classes, and I needed only 2 dependencies in my pom.xml:&lt;br /&gt;&lt;pre style="line-height: 100%;font-family:courier new;font-size:80%;background-color:#ffffff; border-width:0.01mm; border-color:#000000; border-style:solid; padding:4px;"&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;dependency&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;    &lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;groupId&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;font-weight:bold;"&gt;javax.servlet&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;groupId&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;    &lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;artifactId&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;font-weight:bold;"&gt;servlet-api&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;artifactId&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;    &lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;version&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;font-weight:bold;"&gt;2.5&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;version&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;    &lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;scope&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;font-weight:bold;"&gt;provided&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;scope&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;dependency&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;dependency&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;    &lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;groupId&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;font-weight:bold;"&gt;com.sun.jersey&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;groupId&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;    &lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;artifactId&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;font-weight:bold;"&gt;jersey&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;artifactId&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;    &lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;version&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;font-weight:bold;"&gt;${jersey.version}&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;version&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000080;background-color:#efefef;font-weight:bold;"&gt;dependency&lt;/span&gt;&lt;span style="background-color:#efefef;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h4&gt;XStream Message Reader and Writer&lt;/h4&gt;&lt;br /&gt;Most of my object model classes are using XStream, so I wanted Jersey to marshall/unmarshall automatically any XStream class. It was amazingly easy, here is my XStream message reader provider class:&lt;br /&gt;&lt;pre style="line-height: 100%;font-family:courier new;font-size:80%;background-color:#ffffff; border-width:0.01mm; border-color:#000000; border-style:solid; padding:4px;"&gt;&lt;span style="color:#808000;background-color:#ffffff;"&gt;@ProduceMime(&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;{&lt;/span&gt;&lt;span style="color:#008000;background-color:#ffffff;font-weight:bold;"&gt;"application/xml"&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;, &lt;/span&gt;&lt;span style="color:#008000;background-color:#ffffff;font-weight:bold;"&gt;"text/xml"&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;, &lt;/span&gt;&lt;span style="color:#008000;background-color:#ffffff;font-weight:bold;"&gt;"*/*"&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;})&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#808000;background-color:#ffffff;"&gt;@ConsumeMime(&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;{&lt;/span&gt;&lt;span style="color:#008000;background-color:#ffffff;font-weight:bold;"&gt;"application/xml"&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;, &lt;/span&gt;&lt;span style="color:#008000;background-color:#ffffff;font-weight:bold;"&gt;"text/xml"&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;, &lt;/span&gt;&lt;span style="color:#008000;background-color:#ffffff;font-weight:bold;"&gt;"*/*"&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;})&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#808000;background-color:#ffffff;"&gt;@Provider&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;public&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;class&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; XStreamAliasProvider &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;extends&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; AbstractMessageReaderWriterProvider&amp;lt;Object&amp;gt; {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;private&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;static&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;final&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; Set&amp;lt;Class&amp;gt; &lt;/span&gt;&lt;span style="color:#660e7a;background-color:#ffffff;font-weight:bold;font-style:italic;"&gt;processed &lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;= &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;new&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; HashSet&amp;lt;Class&amp;gt;();&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;private&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;static&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;final&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; XStream &lt;/span&gt;&lt;span style="color:#660e7a;background-color:#ffffff;font-weight:bold;font-style:italic;"&gt;xstream &lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;= &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;new&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; XStream();&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;private&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;static&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;final&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; String &lt;/span&gt;&lt;span style="color:#660e7a;background-color:#ffffff;font-weight:bold;font-style:italic;"&gt;DEFAULT_ENCODING &lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;= &lt;/span&gt;&lt;span style="color:#008000;background-color:#ffffff;font-weight:bold;"&gt;"utf-8"&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;;&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;public&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;boolean&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; isReadable(Class&amp;lt;?&amp;gt; type, Type genericType, Annotation annotations[]) {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;return&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; type.getAnnotation(&lt;/span&gt;&lt;span style="color:#808000;background-color:#ffffff;"&gt;XStreamAlias.&lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;class&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;) != &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;null&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;public&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;boolean&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; isWriteable(Class&amp;lt;?&amp;gt; type, Type genericType, Annotation annotations[]) {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;return&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; type.getAnnotation(&lt;/span&gt;&lt;span style="color:#808000;background-color:#ffffff;"&gt;XStreamAlias.&lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;class&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;) != &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;null&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;protected&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;static&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; String getCharsetAsString(MediaType m) {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;if&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; (m == &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;null&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;) {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;return&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#660e7a;background-color:#ffffff;font-weight:bold;font-style:italic;"&gt;DEFAULT_ENCODING;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;        }&lt;br /&gt;        String result = m.getParameters().get(&lt;/span&gt;&lt;span style="color:#008000;background-color:#ffffff;font-weight:bold;"&gt;"charset"&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;);&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;return&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; (result == &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;null&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;) ? &lt;/span&gt;&lt;span style="color:#660e7a;background-color:#ffffff;font-weight:bold;font-style:italic;"&gt;DEFAULT_ENCODING &lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;: result;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;protected&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; XStream getXStream(Class type) {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;synchronized&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; (&lt;/span&gt;&lt;span style="color:#660e7a;background-color:#ffffff;font-weight:bold;font-style:italic;"&gt;processed)&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;if&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; (!&lt;/span&gt;&lt;span style="color:#660e7a;background-color:#ffffff;font-weight:bold;font-style:italic;"&gt;processed.&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;contains(type)) {&lt;br /&gt;                &lt;/span&gt;&lt;span style="color:#660e7a;background-color:#ffffff;font-weight:bold;font-style:italic;"&gt;xstream.&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;processAnnotations(type);&lt;br /&gt;                &lt;/span&gt;&lt;span style="color:#660e7a;background-color:#ffffff;font-weight:bold;font-style:italic;"&gt;processed.&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;add(type);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;return&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#660e7a;background-color:#ffffff;font-weight:bold;font-style:italic;"&gt;xstream;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;public&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; Object readFrom(Class&amp;lt;Object&amp;gt; aClass, Type genericType, Annotation[] annotations,&lt;br /&gt;            MediaType mediaType, MultivaluedMap&amp;lt;String, String&amp;gt; map, InputStream stream)&lt;br /&gt;            &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;throws&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; IOException, WebApplicationException {&lt;br /&gt;        String encoding = &lt;/span&gt;&lt;span style="background-color:#ffffff;font-style:italic;"&gt;getCharsetAsString(&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;mediaType);&lt;br /&gt;        XStream xStream = getXStream(aClass);&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;return&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; xStream.fromXML(&lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;new&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; InputStreamReader(stream, encoding));&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;public&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;void&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; writeTo(Object o, Class&amp;lt;?&amp;gt; aClass, Type type, Annotation[] annotations,&lt;br /&gt;            MediaType mediaType, MultivaluedMap&amp;lt;String, Object&amp;gt; map, OutputStream stream)&lt;br /&gt;            &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;throws&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; IOException, WebApplicationException {&lt;br /&gt;        String encoding = &lt;/span&gt;&lt;span style="background-color:#ffffff;font-style:italic;"&gt;getCharsetAsString(&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;mediaType);&lt;br /&gt;        XStream xStream = getXStream(o.getClass());&lt;br /&gt;        xStream.toXML(o, &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;new&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; OutputStreamWriter(stream, encoding));&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h4&gt;Spring integration&lt;/h4&gt;&lt;br /&gt;All my backend objects are Spring service bean, so I wanted autowired injection of Spring beans. Here again it was really nice. I defined my own annotation @SpringAutowired, and created a SpringBeanInjector for it that was fetching my context for a bean of the type of the injected field. Here I'm adding manually the list of "injectable" interfaces, because: I don't have an annotation to identify them :) With EJB3 it should be a lot cleaner to use @Stateless.&lt;br /&gt;Here is my annotation:&lt;br /&gt;&lt;pre style="line-height: 100%;font-family:courier new;font-size:80%;background-color:#ffffff; border-width:0.01mm; border-color:#000000; border-style:solid; padding:4px;"&gt;&lt;span style="color:#808000;background-color:#ffffff;"&gt;@Target(&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;{ElementType.&lt;/span&gt;&lt;span style="color:#660e7a;background-color:#ffffff;font-weight:bold;font-style:italic;"&gt;PARAMETER,&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; ElementType.&lt;/span&gt;&lt;span style="color:#660e7a;background-color:#ffffff;font-weight:bold;font-style:italic;"&gt;METHOD,&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; ElementType.&lt;/span&gt;&lt;span style="color:#660e7a;background-color:#ffffff;font-weight:bold;font-style:italic;"&gt;FIELD}&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#808000;background-color:#ffffff;"&gt;@Retention(&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;RetentionPolicy.&lt;/span&gt;&lt;span style="color:#660e7a;background-color:#ffffff;font-weight:bold;font-style:italic;"&gt;RUNTIME)&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#808000;background-color:#ffffff;"&gt;@Documented&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;public&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; @&lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;interface&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#808000;background-color:#ffffff;"&gt;SpringAutowired &lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;{&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And here the bean injector class as inner class of my Servlet:&lt;br /&gt;&lt;pre style="line-height: 100%;font-family:courier new;font-size:80%;background-color:#ffffff; border-width:0.01mm; border-color:#000000; border-style:solid; padding:4px;"&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;public&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;class&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; ArtifactoryRestServlet &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;extends&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; ServletContainer {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#808000;background-color:#ffffff;"&gt;@Override&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;protected&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;void&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; configure(ServletConfig config, ResourceConfig rc,&lt;br /&gt;            WebApplication application) {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;super&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;.configure(config, rc, application);&lt;br /&gt;&lt;br /&gt;        Set&amp;lt;Object&amp;gt; pi = rc.getProviderInstances();&lt;br /&gt;        pi.add(&lt;/span&gt;&lt;span style="background-color:#ffffff;font-style:italic;"&gt;getSpringBeanInjector(&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;AuthorizationService.&lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;class&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;));&lt;br /&gt;        pi.add(&lt;/span&gt;&lt;span style="background-color:#ffffff;font-style:italic;"&gt;getSpringBeanInjector(&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;CentralConfigService.&lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;class&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;));&lt;br /&gt;        pi.add(&lt;/span&gt;&lt;span style="background-color:#ffffff;font-style:italic;"&gt;getSpringBeanInjector(&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;UserGroupService.&lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;class&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;));&lt;br /&gt;        pi.add(&lt;/span&gt;&lt;span style="background-color:#ffffff;font-style:italic;"&gt;getSpringBeanInjector(&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;AclService.&lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;class&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;));&lt;br /&gt;        pi.add(&lt;/span&gt;&lt;span style="background-color:#ffffff;font-style:italic;"&gt;getSpringBeanInjector(&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;RepositoryService.&lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;class&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;));&lt;br /&gt;        pi.add(&lt;/span&gt;&lt;span style="background-color:#ffffff;font-style:italic;"&gt;getSpringBeanInjector(&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;ArtifactoryContext.&lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;class&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;));&lt;br /&gt;        pi.add(&lt;/span&gt;&lt;span style="background-color:#ffffff;font-style:italic;"&gt;getSpringBeanInjector(&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;SecurityService.&lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;class&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;));&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;public&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;static&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &amp;lt;T&amp;gt; SpringBeanInjector&amp;lt;T&amp;gt; getSpringBeanInjector(Class&amp;lt;T&amp;gt; beanInterface) {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;return&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;new&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; SpringBeanInjector&amp;lt;T&amp;gt;(beanInterface);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;public&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;static&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;class&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; SpringBeanInjector&amp;lt;T&amp;gt;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;implements&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; InjectableProvider&amp;lt;&lt;/span&gt;&lt;span style="color:#808000;background-color:#ffffff;"&gt;SpringAutowired,&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; Type&amp;gt;, Injectable&amp;lt;T&amp;gt; {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;private&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; Class&amp;lt;T&amp;gt; &lt;/span&gt;&lt;span style="color:#660e7a;background-color:#ffffff;font-weight:bold;"&gt;type;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;        &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;public&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; SpringBeanInjector(Class&amp;lt;T&amp;gt; t) {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;this&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;.&lt;/span&gt;&lt;span style="color:#660e7a;background-color:#ffffff;font-weight:bold;"&gt;type &lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;= t;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;public&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; ComponentProvider.Scope getScope() {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;return&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; ComponentProvider.Scope.&lt;/span&gt;&lt;span style="color:#660e7a;background-color:#ffffff;font-weight:bold;font-style:italic;"&gt;PerRequest;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;public&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; Injectable getInjectable(ComponentContext ic,&lt;br /&gt;                &lt;/span&gt;&lt;span style="color:#808000;background-color:#ffffff;"&gt;SpringAutowired &lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;autowired, Type type) {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;if&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; (type.equals(&lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;this&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;.&lt;/span&gt;&lt;span style="color:#660e7a;background-color:#ffffff;font-weight:bold;"&gt;type)&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;) {&lt;br /&gt;                &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;return&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;this&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;;&lt;br /&gt;            } &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;else&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; {&lt;br /&gt;                &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;return&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;null&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;public&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; T getValue(HttpContext context) {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color:#808080;background-color:#ffffff;font-style:italic;"&gt;/*&lt;br /&gt;            (ArtifactoryContext) context&lt;br /&gt;                    .getAttribute("org.springframework.web.context.ROOT");&lt;br /&gt;            */&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;            ArtifactoryContext springContext = ContextHelper.&lt;/span&gt;&lt;span style="background-color:#ffffff;font-style:italic;"&gt;get(&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;);&lt;br /&gt;            &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;if&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; (springContext == &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;null&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;) {&lt;br /&gt;                &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;return&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;null&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;;&lt;br /&gt;            }&lt;br /&gt;            &lt;/span&gt;&lt;span style="color:#000080;background-color:#ffffff;font-weight:bold;"&gt;return&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt; springContext.beanForType(&lt;/span&gt;&lt;span style="color:#660e7a;background-color:#ffffff;font-weight:bold;"&gt;type)&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h4&gt;Conclusion&lt;/h4&gt;&lt;br /&gt;I really liked the WebBeans consept and the Guice injection, but actually working with these nice modern Framework architecture on a real case proved that's the way to go.&lt;br /&gt;Morale: "Chapeau bas for Paul Sandoz at Sun"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-8955220872826436763?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/8955220872826436763/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=8955220872826436763' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/8955220872826436763'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/8955220872826436763'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2008/07/using-jersey-for-exposing-rest-services.html' title='Using Jersey for exposing REST services'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-24107835441638335</id><published>2008-02-29T21:11:00.001+02:00</published><updated>2008-02-29T21:31:36.665+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='stellarium'/><category scheme='http://www.blogger.com/atom/ns#' term='javaone'/><title type='text'>Stellarium For Java Alpha release!</title><content type='html'>After a lot of ups and downs, we (Jerome Beau and myself) are really happy to release an alpha version of Stellarium For Java (S4J in short).&lt;br /&gt;This project is a migration of the very successful C++ project &lt;a href="http://stellarium.org/"&gt;Stellarium&lt;/a&gt; created by Fabien Chereau.&lt;br /&gt;For the record, I really like this C++ version but I am missing a lot of features:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Ability to add stars catalogs like in &lt;a href="http://celestia.sourceforge.net/"&gt;Celestia&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Loading data on demand from the web instead of the resources in the installation&lt;/li&gt;&lt;li&gt;Resizable window (I have a Widescreen and need to play with config file)&lt;/li&gt;&lt;/ol&gt;So, as a open source minded guy, I looked inside the code... And I got flashbacks! I found myself, back in time, when I was doing C++ for Video servers, and MFC applications.&lt;br /&gt;I laughed, and then tried to find a Java version of any Astronomy software. I found &lt;a href="http://stellarium4java.sourceforge.net/"&gt;Stellarium4Java&lt;/a&gt;.&lt;br /&gt;The project had started a year before with Jerome and Arnaud Barre. At the time, it was in the middle of the pure code migration from Stellarium C++ to Java.&lt;br /&gt;It looked like a small decision at the time, so I joined the project! Today I can say: It took time and energy to get were we are today.&lt;br /&gt;But, thanks to the great work of the JOGL team in Sun, and all the Java open source projects, &lt;a href="https://stellarium4java.dev.java.net/files/documents/4463/87940/stellarium.jnlp"&gt;here&lt;/a&gt; or &lt;a href="http://stellarium4java.sourceforge.net/stellarium4java/jnlp/stellarium.jnlp"&gt;here&lt;/a&gt; is the alpha version loading with Web Start. I'm still working on the web distribution of resources, so for the moment you will have to wait for 13Mo of download :(&lt;br /&gt;There is a &lt;a href="http://www.jfrog.org/confluence/display/S4J/Welcome+to+Stellarium4java"&gt;Wiki page&lt;/a&gt; on jfrog with the jnlp links (they are still a moving target ;-) and the bug report access (be nice it's still alpha:-).&lt;br /&gt;The most interesting part is that we got selected for a presentation at &lt;a href="http://java.sun.com/javaone"&gt;JavaOne&lt;/a&gt; this year to present this application. We will show how Java and the open source projects really helped us doing this, and what features we got for free from Java!&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://java.sun.com/javaone"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: left; cursor: pointer; width: 170px;" src="http://java.sun.com/javaone/images/2008/170x93_Speaker_v4.gif" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Side note: This project makes me love Java, every time I'm freeing myself for it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-24107835441638335?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/24107835441638335/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=24107835441638335' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/24107835441638335'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/24107835441638335'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2008/02/stellarium-for-java-alpha-release.html' title='Stellarium For Java Alpha release!'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-4877913719541361723</id><published>2008-02-18T12:19:00.000+02:00</published><updated>2008-09-03T17:37:50.218+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='jcp'/><category scheme='http://www.blogger.com/atom/ns#' term='openjdk'/><title type='text'>Closure Campaign 2008</title><content type='html'>After many discussion, it is &lt;a href="http://java.net/pub/pq/196"&gt;election time (year) for closure&lt;/a&gt;.&lt;br /&gt;I voted for the readable, easy to grasp, and "almost" complete implementation of closure: FCM.&lt;br /&gt;The posts of Stephen on the differences are very instructive:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;a href="http://www.jroller.com/scolebourne/entry/closures_comparing_the_core_of"&gt;Closures - Comparing the core of BGGA, CICE and FCM&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.jroller.com/scolebourne/entry/closures_comparing_control_structures_of"&gt;Closures - Comparing control structures of BGGA, ARM and JCA&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.jroller.com/scolebourne/entry/java_7_comparing_closure_type"&gt;Closures - Comparing closure type inference&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;I hope this vote will have an influence on the JCP...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-4877913719541361723?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/4877913719541361723/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=4877913719541361723' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/4877913719541361723'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/4877913719541361723'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2008/02/closure-campaign-2008.html' title='Closure Campaign 2008'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-8454067043227271684</id><published>2008-01-28T21:54:00.000+02:00</published><updated>2008-01-29T09:06:56.565+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wild'/><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='webbeans'/><category scheme='http://www.blogger.com/atom/ns#' term='properties'/><category scheme='http://www.blogger.com/atom/ns#' term='kijaro'/><category scheme='http://www.blogger.com/atom/ns#' term='openjdk'/><title type='text'>Wild Java Properties, The Wild Part</title><content type='html'>Following &lt;a href="http://freddy33.blogspot.com/2008/01/wild-java-properties-road-so-far.html"&gt;my previous blog entry&lt;/a&gt;, I tried to use Remi's property implementation for JPA or WebBeans. These 2 recent (WebBeans being still in diapers) frameworks really represent what I need from the property proposal. Generally I'd like to be able to do things like:&lt;br /&gt;&lt;h4&gt;JPA (Hibernate)&lt;/h4&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@Id&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public property&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;long&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; id get;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@Column(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"FIRST_NAME"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt; property&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;firstName;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; Criteria(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person&lt;/span&gt;&lt;span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;#&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;firstName,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; value);&lt;/span&gt;&lt;/pre&gt;&lt;h4&gt;Validations&lt;/h4&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;protected&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &amp;lt;B,T&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; propertyChanged(&lt;br /&gt;java.lang.Property&amp;lt;B,T&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;property,&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;&lt;br /&gt;Object &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;oldValue,&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Object &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;newValue)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255); font-style: italic;"&gt;// Activate validation rules and so stop setting the value&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt; &lt;/span&gt;&lt;/pre&gt;&lt;h4&gt;WebBeans (JSR-299) or Guice&lt;/h4&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@Log&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;static&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt; property&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Logger &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;log;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;h4&gt;Wicket or Swing&lt;/h4&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; TextField(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person&lt;/span&gt;&lt;span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;#&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;firstName)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; DynamicPanel().addAll(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;.properties());&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;I'd like to say that Remi's work is truly amazing and is a good first draft. It is open source for us to analyze and contribute to. The benefits of properties in the cases above are:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;No issue of annotations on either a field and/or getter/setter methods. All is centralized on one property declaration.&lt;/li&gt;&lt;li&gt;No reflection. All method calls from and to the framework are compiled and wired without using reflection. This is a great boost for UI and Dependency Injection framework.&lt;/li&gt;&lt;li&gt;Introspection without reflection.&lt;/li&gt;&lt;/ol&gt;Trying to write the properties for the logger example (in fact any DI/IoC framework) and validations framework, I found that this implementation is not helping, and even worse - It's stopping me from doing what I need. Here are the limitations:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;The first problem I encountered is that writing get and set blocks inline looks really good but breaks Object Orientation. I cannot do inheritance or use polymorphisms in these blocks. I ended up having more boilerplate code than without the usage of properties.&lt;/li&gt;&lt;li&gt;The second is that the private field exists only if there is no get/set block. So, if you wish to write getter/setter that uses a field, you need to declare this field. Suddenly, a lot of the generated syntactic sugar disappears and you find yourself writing almost as much as before.&lt;/li&gt;&lt;li&gt;The third issue is that encapsulation is asymmetric. What I mean by that is &lt;span style="font-family:courier new;"&gt;System.out.println(firstName)&lt;/span&gt; will use directly the field, but &lt;span style="font-family:courier new;"&gt;this.firstName = "toto"&lt;/span&gt; will become &lt;span style="font-family:courier new;"&gt;this.setFirstName("toto");&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;So, I tried to see how I can solve these limitations. Since modularity is the most important  feature for me, a clean solution for the DI framework property issue is critical. This can really turn Java into a true Component based platform at its root. So as for the Logger issue I actually want to write:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;static&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt; property&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Logger &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;log&lt;br /&gt;init {&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;log &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Logger.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255); font-style: italic;"&gt;getLogger(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;.getName());};&lt;/span&gt;&lt;/pre&gt;I added here some &lt;span style="font-family:courier new;"&gt;init&lt;/span&gt; block in the same line as the get/set block, since this is really what I want - to declare how the field is initialized. But, I'd like to write this once and reuse it. Furthermore, I want the &lt;span style="font-family:courier new;"&gt;init&lt;/span&gt; to be executed when the field (either static or instance) is declared, or on demand (lazy init). The only good way to do it is to have a class wrapping the Type2 property. It would look something like:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;final&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;static&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Property&amp;lt;Logger&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;log &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; LazyInitProperty() {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;protected&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; init() {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;value &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Logger.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255); font-style: italic;"&gt;getLogger(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;.getName());&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        }&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    };&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;final&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Property&amp;lt;String&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;lastName &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Property&amp;lt;String&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;();&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Property&amp;lt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;T&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;implements&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; BaseProperty&amp;lt;T&amp;gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; T &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;value;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; T get() {&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;value;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; set(T &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;value)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;this&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;value &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;value;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public abstract&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; LazyInitProperty&amp;lt;T&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;implements&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; ReadOnlyProperty&amp;lt;T&amp;gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;protected&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; T &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;value;&lt;br /&gt;&lt;/span&gt; &lt;span style="background-color: rgb(255, 255, 255);"&gt;   &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; T get() {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; (&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;value &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;== &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            init();&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;value;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;protected&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;abstract&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; init();&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;Of course it is missing a lot of good (or not) &lt;span style="font-family:courier new;"&gt;synchronized&lt;/span&gt;, but the idea is here. Basically I ended up with the &lt;a href="http://joda.sourceforge.net/beans.html"&gt;Joda Beans&lt;/a&gt; or &lt;a href="https://bean-properties.dev.java.net/"&gt;java.net bean properties&lt;/a&gt; concept, and also Yardena's &lt;a href="http://sensualjava.blogspot.com/2007/11/properties-static-and-yet-dynamic.html"&gt;idea&lt;/a&gt;.&lt;br /&gt;This is an old idea about the notion that properties don't need to be a language feature. Take a look at &lt;a href="https://bean-properties.dev.java.net/10things.html"&gt;What Makes Bean-Properties Special&lt;/a&gt;, and 2 discussions on The Java Posse Google group: &lt;a href="http://groups.google.com/group/javaposse/browse_thread/thread/800fd874d9366df2"&gt; Wonder what Joe thinks of this properties solution&lt;/a&gt;, &lt;a href="http://groups.google.com/group/javaposse/browse_thread/thread/a49aaef19d0efd21/2088555d8ed8d3b4?lnk=gst&amp;amp;q=properties#2088555d8ed8d3b4"&gt;Still hope for first-class properties&lt;/a&gt;.&lt;br /&gt;&lt;h4&gt;Conclusion&lt;/h4&gt;The solution to all of my problems: &lt;b&gt;Properties should not be a language feature!&lt;/b&gt;&lt;br /&gt;When I got there for the first time I thought: WTF! But that's a logical step, isn't it? Properties are field level encapsulation with accessors and events. You can do this in any OO language with a class wrapping your field. So &lt;span style="font-weight: bold;"&gt;why are we suffering?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The main problem with open source properties projects is that all the classes and interfaces of PropertyType2&amp;lt;T&amp;gt; and PropertyType1&amp;lt;B,T&amp;gt; belong in the JDK. They need to be made a standard so that all framework and component will use them. To be useful, the bean-properties project needs to be in a JSR and included in Java 7. Why didn't any open source property project became a de-facto standard? It's amazing how many Property classes already exists out there!&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Joda does binding with no boilerplate but changes the getter/setter style.&lt;/li&gt;&lt;li&gt;Bean-properties does the binding boilerplate code (and even setter/getter) with bytecode generation. Personally I prefer good syntactic sugar.&lt;/li&gt;&lt;li&gt;Annotations on these specific "Property" fields are not understood by 3rd party framework like JPA.&lt;/li&gt;&lt;li&gt;You need to declare public final fields.&lt;/li&gt;&lt;li&gt;Even if the amount of code is quite low, you still repeat yourself in the field declaration.&lt;/li&gt;&lt;li&gt;Bean introspection and Property object access are done using Strings and reflection.&lt;/li&gt;&lt;li&gt;The amount of features (Read, Write, initialized, Lazy, bind), types (Simple, Array, Set, Map,...), Modifiers (private, public, synchronized, volatile, for field/getter/setter), are generating a combinator which is impossible to implement with a Property&amp;lt;T&amp;gt; class hierarchy.&lt;/li&gt;&lt;/ol&gt;Personally, I don't find items 1 and 4 to be a problem. The getter/setter style is related to encapsulation. It's the OO convention for dealing with properties. For me, automatically transforming &lt;span style="font-family:courier new;"&gt;person.firstName="toto";&lt;/span&gt; to &lt;span style="font-family:courier new;"&gt;person.setFirstName("toto");&lt;/span&gt; in Java today is very confusing. With Joda style, the type of &lt;span style="font-family:courier new;"&gt;person.firstName&lt;/span&gt; is &lt;span style="font-family:courier new;"&gt;Property&amp;lt;String&amp;gt;&lt;/span&gt;, so when "toto" is assigned to it, something needs to box the value! Transforming &lt;span style="font-family:courier new;"&gt;person.firstName="toto";&lt;/span&gt; to &lt;span style="font-family:courier new;"&gt;person.firstName.set("toto");&lt;/span&gt; looks very close to the boxing/unboxing feature, doesn't it? Basically I feel comfortable with the idea that if you want to encapsulate a field in a Property, you should use a class for the encapsulation, not getXXX() and setXXX() methods. And if it's a class, make it clear, don't hide it. So, as for point 4 - a property may be visible or not. Here, I have a strong issue with visibility control around the field, getter, setter trio. Today, I do use different modifiers for each of them. Is it really useful?&lt;br /&gt;&lt;h4&gt;So what!&lt;/h4&gt;Well, my final wild idea is:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;I want a unique Type1 interface in the JDK (like Remi's &lt;span style="font-family:courier new;"&gt;Property&amp;lt;B,T&amp;gt;&lt;/span&gt;) called &lt;span style="font-family:courier new;"&gt;PropertyAdaptor&amp;lt;B,T&amp;gt;&lt;/span&gt; to be separated from bean-properties class. This can (and will in my kijaro branch) be implemented with an abstract enum.&lt;/li&gt;&lt;li&gt;I want &lt;span style="font-family:courier new;"&gt;Person#firstName&lt;/span&gt; to return the above Type1 enum instance, and then use it to remove the need to change the class format (similar to what needs to be done in Remi's implementation today).&lt;/li&gt;&lt;li&gt;I want a nice, small and simple Type2 property interfaces and classes hierarchy, that are making a heavy usage of Annotations and the above unique Type1 enum entry for initialization. Basically this means making some "kind of" bean-properties project part of the Kijaro JDK (KDK ;-).&lt;/li&gt;&lt;li&gt;The Type1 methods "&lt;span style="font-family:courier new;"&gt;T get(B)&lt;/span&gt;" and "&lt;span style="font-family:courier new;"&gt;void set(B,T)&lt;/span&gt;" should delegate (by the javac phase) to "&lt;span style="font-family:courier new;"&gt;T get()&lt;/span&gt;" and "&lt;span style="font-family:courier new;"&gt;set(T)&lt;/span&gt;" of the Type2 instance. This would remove the need for reflection.&lt;/li&gt;&lt;li&gt;There should be no restrictions on extending classes or interfaces in the JDK based &lt;span style="font-family:courier new;"&gt;Property&amp;lt;T&amp;gt;&lt;/span&gt; (Type2) hierarchy and on using them. This way, WebBeans and JPA can provide state-of-the-art properties implementations tuned  for their needs. This would provide the loose coupling and transparent state management at a language level without reflection.&lt;/li&gt;&lt;li&gt;The property keyword should be replaced by the above annotation. This Annotation will activate all the syntactic sugar that would remove the standard properties boilerplate code. But, most of the actual Type2 implementation will come from the super class and extra annotations.&lt;/li&gt;&lt;/ul&gt;Each time I apply the concept of Type2 property class provided and implemented by frameworks, I find a new way to clean and optimize my code:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Dependency Injection (OSGi), dynamic object allocation and redirection - can be done by calling set on the required properties, by having a smart get or by setting a dirty flag. Whatever the solution be, it is totally transparent to the business code declaring the property field.&lt;/li&gt;&lt;li&gt;Persistence framework providing validations (from DB type, data and annotations) and listening to property changes.&lt;/li&gt;&lt;li&gt;Swing bindings of course, but used by higher level framework that can manage full business objects and all their properties.&lt;/li&gt;&lt;/ul&gt;&lt;h4&gt;What I'm gonna' do!&lt;/h4&gt; Independently of the wild crazy idea of properties by annotation as a language feature, the property list introspection will be done using a unique abstract enum  &lt;span style="font-family:courier new;"&gt;java.property.PropertyDefinition&amp;lt;B,T&amp;gt;&lt;/span&gt;:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;abstract&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;enum&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; PropertyDefinition&amp;lt;B, T&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;implements&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;PropertyAdaptor&amp;lt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;B, T&amp;gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;abstract&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; T get(B &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;bean)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;abstract&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; set(B &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;bean,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; T &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;newValue)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public abstract&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Property&amp;lt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;T&amp;gt; getProperty(B &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;bean)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;propertyName() {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; name();&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Class&amp;lt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;B&amp;gt; getBeanClass() {...&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Class&amp;lt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;T&amp;gt; getPropertyType() {...&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Annotation[&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;] getAnnotations() {...&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;boolean&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; isReadable() {...&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;boolean&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; isWritable() {...&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; getFieldModifiers() {...&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; getGetterModifiers() {...&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; getSetterModifiers() {...&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;And the javac generated code will look like:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;[...]&lt;span style="font-family:mon;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;static&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;enum&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;properties&amp;lt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;T&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;extends&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;PropertyDefinition&lt;/span&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;T&amp;gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &amp;lt;String&amp;gt; firstName,&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &amp;lt;String&amp;gt; lastName,&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &amp;lt;Integer&amp;gt; age&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt; &lt;/span&gt;&lt;/pre&gt;The above work is a simple merge of Remi's implementation and the abstract enum. On top of that, I'll implement the generic Type2 thing. First an annotation needs to be associated with a &lt;span style="font-family:courier new;"&gt;Property&amp;lt;T&amp;gt;&lt;/span&gt; (Type2) abstract class. I'll use a meta-annotation &lt;span style="font-family:courier new;"&gt;PropertyClass&lt;/span&gt;, so anyone can declare a future &lt;span style="font-family:courier new;"&gt;@Property&lt;/span&gt; annotation.&lt;br /&gt;&lt;br /&gt;The meta annotation:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@Retention(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;RetentionPolicy.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;RUNTIME)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@Target(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ElementType.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;ANNOTATION_TYPE)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; @&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;interface&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;PropertyClass &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Class &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;value();&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;The specific annotation for a basic property:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@Retention(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;RetentionPolicy.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;RUNTIME)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@Target(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ElementType.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;FIELD)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@PropertyClass(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;BasePropertyImpl.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; @&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;interface&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;BasicProperty &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;PropertyAccess &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;value();&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;The specific annotation for a property that can be bound:&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@Retention(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;RetentionPolicy.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;RUNTIME)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@Target(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ElementType.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;FIELD)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@PropertyClass(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ObservablePropertyImpl.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; @&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;interface&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;ObservableProperty &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255); font-style: italic;"&gt;// Using FCM&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;#&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;PropertyStateEvent)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; onSet &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;default&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;Then, the bean class:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@BasicProperty(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;PropertyAccess.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;READ_WRITE)&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;firstName;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@ObservableProperty(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person&lt;/span&gt;&lt;span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;#&lt;/span&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;firstNameChanged)&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;lastName;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@BasicProperty(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;PropertyAccess.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;READ_ONLY)&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;age;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; firstNameChanged(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;PropertyStateEvent &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;se)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;System.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;out.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;println(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"property changed "&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;se)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;And so the boilerplate code generated by javac will look like:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@BasicProperty(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;PropertyAccess.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;READ_WRITE)&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;final&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;BasePropertyImpl&amp;lt;String&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; firstName =&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; BasePropertyImpl&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;(properties.firstName);&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@ObservableProperty(&lt;/span&gt;&lt;span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;#&lt;/span&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;firstNameChanged)&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;final&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ObservablePropertyImpl&amp;lt;String&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; lastName =&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; ObservablePropertyImpl&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;(properties.lastName);&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@BasicProperty(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;PropertyAccess.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;READ_ONLY)&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;final&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;BasePropertyImpl&amp;lt;Integer&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; age =&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; BasePropertyImpl&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Integer&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;(properties.age);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; firstNameChanged(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;PropertyStateEvent &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;se)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;System.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;out.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;println(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"property changed "&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;se)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;static&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;enum&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;properties&amp;lt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;T&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;extends&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;PropertyDefinition&amp;lt;Person,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;T&amp;gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &amp;lt;String&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;firstName,&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &amp;lt;String&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;lastName,&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &amp;lt;Integer&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;age&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;    &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;And all accessors to &lt;span style="font-family:courier new;"&gt;person.firstName&lt;/span&gt; will be wrapped in javac with &lt;span style="font-family:courier new;"&gt;person.firstName.set() &lt;/span&gt;and &lt;span style="font-family:courier new;"&gt;person.firstName.get()&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;This proposition respects Object Orientation, it is very flexible and open for future extension. It removes a lot of boilerplate code and makes Java ready for easy-to-use components. For example, by applying this solution IoC frameworks can really be "inverted". What I mean by that is that instead of trying to invoke setXXX() on the components at the right time (object life cycle and/or component state), they can simply provide a state-of-the-art getter in the property type2 class that will fetch the right object at the right time, all the time. This is transparent decoupling, keeping type safety and without using reflection.&lt;br /&gt;&lt;br /&gt;So it solves some (but not all) of the issues like:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Yardena's need for &lt;a href="http://sensualjava.blogspot.com/2007/11/null-safe-access-to-properties.html"&gt;flexible property behavior&lt;/a&gt; and &lt;a href="http://sensualjava.blogspot.com/2007/11/walls-and-bridges.html"&gt;generics issue with properties&lt;/a&gt;,&lt;/li&gt;&lt;li&gt;Eric Burke's ability to have &lt;a href="http://stuffthathappens.com/blog/2007/11/19/my-own-java-7-suggestion/"&gt;more flexible binding&lt;/a&gt;&lt;/li&gt;&lt;li&gt;My need for using FCM pointer in properties declaration. Which methods init, bind, listen, and so on.&lt;/li&gt;&lt;/ul&gt;The only thing that property as a language feature will have a hard time providing is dynamic creation of properties, but that's another story.&lt;br /&gt;&lt;br /&gt;A few more white nights are ahead of me so I can put all this in kijaro, I guess ;-) Unless someone finds a good reason to stop me in my wild Java experience!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-8454067043227271684?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/8454067043227271684/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=8454067043227271684' title='12 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/8454067043227271684'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/8454067043227271684'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2008/01/wild-java-properties-wild-part.html' title='Wild Java Properties, The Wild Part'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>12</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-8680231892926375914</id><published>2008-01-28T12:51:00.000+02:00</published><updated>2008-01-29T08:19:51.580+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wild'/><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='properties'/><category scheme='http://www.blogger.com/atom/ns#' term='kijaro'/><category scheme='http://www.blogger.com/atom/ns#' term='openjdk'/><title type='text'>Wild Java Properties, The Road So Far</title><content type='html'>First I'd like to thank Alex Miller for keeping good track of links regarding &lt;a href="http://tech.puredanger.com/java7#property"&gt;properties in Java 7&lt;/a&gt;,&lt;br /&gt;I don't have to repeat them!&lt;br /&gt;&lt;br /&gt;I'll just add a few links:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The &lt;a href="http://kijaro.dev.java.net/"&gt;kijaro&lt;/a&gt; project has the first version of Remi Forax's Property implementation.&lt;/li&gt;&lt;li&gt;The &lt;a href="http://docs.google.com/View?docid=dfhbvdfw_1f7mzf2"&gt;google doc&lt;/a&gt; by Remi that documents this first usage of property as a language feature (as far as I know it's the only one).&lt;/li&gt;&lt;li&gt;The usage of this implementation with Beans Binding in Remi's &lt;a href="http://weblogs.java.net/blog/forax/archive/2007/09/mixing_property_1.html"&gt;blog entry&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;After integrating my work on Abstract Enum in the kijaro project (&lt;a href="https://kijaro.dev.java.net/svn/kijaro/branches/abstractenum/"&gt;abstract enum branch&lt;/a&gt;, &lt;span style="font-style: italic;"&gt;to access it you need to be a kijaro reader&lt;/span&gt;), I started merging Remi Forax's &lt;a href="https://kijaro.dev.java.net/svn/kijaro/branches/properties/"&gt;branch&lt;/a&gt; with one simple goal: Having the list of properties of any class automatically generated (syntactic sugar) as an enum! One of Remi's comments about using enum for property enumeration complained on the inability to use Generics with enums. With Abstract Enum it is possible, and I'll show how here.&lt;br /&gt;&lt;br /&gt;The benefits of using abstract enum to enumerate properties are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Easy and type-safe properties introspection: MyClass.Property.values() returns the collection of MyClass.Property&amp;lt;MyClass,?&amp;gt;;&lt;/li&gt;&lt;li&gt;Easy and type safe conversion from a string to a property object: MyClass.Property.valueOf("firstName") returns MyClass.Property&amp;lt;MyClass,String&amp;gt; MyClass#firstName;&lt;/li&gt;&lt;li&gt;I can switch (aProperty) {case firstName:...};&lt;/li&gt;&lt;li&gt;MyClass#myProperty is an instance of MyClass.Property and so I can use == comparator with no risk.&lt;/li&gt;&lt;li&gt;I can use MyClass#myProperty in annotations that accept the abstract Enum PropertyAdaptor as parameter. Things like @LinkTo(Person#firstName).&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Before I started coding I played, reviewed and analyzed the current implementation, and I will try to describe how it works. Here is the basic example using property keyword ("property" is not really a keyword since it can be used only before the type declaration of a member, but anyway):&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public property&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; firstName;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;property&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; lastName;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;property&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;age;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;Analyzing the syntactic sugar generated by Remi's implementation, I needed to clarify where are the Type1 (Bean-independent property: aka per-class, property-proxy, property adaptor) and Type2 (Bean-attached property: aka per-instance) properties classes and instances. These types are nicely defined in Stephen Colebourne's blog &lt;a href="http://www.jroller.com/scolebourne/entry/java_7_properties_terminology"&gt;Java 7 - Properties terminology&lt;/a&gt;. Remi calls the Type1 a "Property Literal" and it is implemented with an anonymous class inheriting from a new class in the JDK: &lt;a href="https://kijaro.dev.java.net/svn/kijaro/branches/abstractenum/jdk/src/share/classes/java/lang/Property.java"&gt;java.lang.Property&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;For Type2 there is no need for a class since the basic property boilerplate code generated is:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;firstName;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;getFirstName() {&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;firstName;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; setFirstName(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;param)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;firstName &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;param;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;The above code is the syntactic sugar created by javac, and so not editable in any way. For the Type1 the generated code is:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;static&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; Property&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; firstName() {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; Property&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;(&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"firstName"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;) {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;get(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;person)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;person.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;getFirstName();}&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; set(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;person,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;s)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;person.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;setFirstName(&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;s)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;}&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    };&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;And for Bean introspection (getting the list of properties) another piece is generated:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;static&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; Property&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;?&amp;gt;[] properties() {&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;$PROPERTIES;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;};&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;static&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; Property&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;?&amp;gt;[] $PROPERTIES = new Property[]{&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255); font-style: italic;"&gt;firstName(),lastName(),age()&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;};&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;This is the code for a basic property, but there are more features implemented like:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Generating a getter method only or a setter method only&lt;/li&gt;&lt;li&gt;Implementing getter and setter inline of the property declaration&lt;/li&gt;&lt;li&gt;And the very powerful 'bound' which allows automatic events on setXXX() without boilerplate code.&lt;/li&gt;&lt;/ul&gt;For example if lastName is read only with a provided block and age is bound, the Person class will be:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; property String firstName;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; property String lastName get { &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"XXX"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;; };&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; property &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; age bound;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;protected&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &amp;lt;B,T&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; propertyChanged(java.lang.Property&amp;lt;B,T&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;property,&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Object &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;oldValue,&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Object &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;newValue)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;System.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;out.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;println(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"property changed "&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;property+&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;" "&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;oldValue+&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;" "&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;newValue)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;Here is the generated code:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;getLastName() {&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"XXX"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;static&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; Property&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; lastName() {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; Property&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;(&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"lastName"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;) {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;get(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;person)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;person.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;getLastName();}&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; set(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;person,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;s)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;throw&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; UnsupportedOperationException();}&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    };&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;age;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; getAge() {&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;age;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; setAge(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;param)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;     &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;oldValue &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;age;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;     &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;age &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;param;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;     &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;this&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;.&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person,Integer&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;propertyChanged(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255); font-style: italic;"&gt;age(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;),&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;oldValue,&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;param)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;static&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; Property&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Integer&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; age() {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; Property&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Integer&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;(&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"age"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;) {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Integer &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;get(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;person)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;person.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;getAge();}&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; set(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Person &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;person,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Integer &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;s)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;person.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;setAge(&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;s)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;}&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    };&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;That's a lot of syntactic sugar, but that's the point of properties, isn't it: &lt;a href="http://smallwig.blogspot.com/2007/10/value-objects-wtf2.html"&gt;Value objects WTF!!?!!2!&lt;/a&gt;. This property implementation works very well for Swing and Beans Binding implementation like Remi's demo shows. You can also write very quickly generic equals and hashcode methods based on the properties list. But, as a backend developer I also need properties.&lt;br /&gt;&lt;br /&gt;Property as language feature is not just syntactic sugar generation it's really solving a problem that just CANNOT be solved in Java today: How can I safely (which means maintaining type safety) pass a field or method (which are the elements that represent a property today - getter/setter) to a framework like JPA, WebBeans, Validations framework, Wicket, Swing Bindings, and all the others developed out there? Today, you NEED to pass a String (EL) and do reflection. That does not make sense. When I know a UI component is bound to  Person.firstName, why do I need to write bind(Person.class, "firstName") and loose type safety, compiler existence check (whether or not firstName property exists), and so refactoring ability.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://freddy33.blogspot.com/2008/01/wild-java-properties-wild-part.html"&gt;Next post&lt;/a&gt;, I'll expose how I wish to have properties for all ;-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-8680231892926375914?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/8680231892926375914/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=8680231892926375914' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/8680231892926375914'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/8680231892926375914'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2008/01/wild-java-properties-road-so-far.html' title='Wild Java Properties, The Road So Far'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-1919196982089985556</id><published>2008-01-28T12:21:00.000+02:00</published><updated>2008-01-28T23:55:10.157+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wild'/><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='kijaro'/><category scheme='http://www.blogger.com/atom/ns#' term='openjdk'/><title type='text'>The Java Wild series!</title><content type='html'>This blog has been silent for more than 2 months now... And this just after I started some good work on the great &lt;a href="http://kijaro.dev.java.net/"&gt;kijaro project&lt;/a&gt;. I'm really happy to say that it was for a great trip to Guatemala where we picked up our newly adopted child.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://lh4.google.com/frederic.simon/R1MC_G6QdqI/AAAAAAAABGU/R_ShWqiBpWU/pasaporte%201.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 158px; height: 212px;" src="http://lh4.google.com/frederic.simon/R1MC_G6QdqI/AAAAAAAABGU/R_ShWqiBpWU/pasaporte%201.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This is the first time ever since I discovered coding (1985) that I did not write one line of code for 2 months in a row ;-) Very relaxing, and I still have a very hard time going back ;-)&lt;br /&gt;&lt;br /&gt;Anyway, even without coding I've spent a lot of time reading blogs and article about The End of Java and other worrying thoughts. All this ended up in this Java Wild entries. Playing with Kijaro and the different patches that can change the Java language clarified what I really want from Java and the platform.&lt;br /&gt;&lt;br /&gt;The conclusion is that the most critical feature needed for Java 7 (and maybe even for 6 update N) is: Modularity. The JDK needs to be built out of nice dependent modules with superpackages and JSR-277 (or OSGi) packaging. This is critical for the future of Java. And Stephen's &lt;a href="http://www.jroller.com/scolebourne/entry/is_the_jcp_broken"&gt;blog entry&lt;/a&gt; about the JCP inefficiency and OSGi vs. JSR-277 war is, for me, the darkest cloud above Java.&lt;br /&gt;&lt;br /&gt;Mostly my thinking about the topics covered in my Java Wild series goes: "If it helps write to modules: good". But beside this I really went wild, and it was fun.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;The first entry is about properties that really got &lt;a href="http://weblogs.java.net/blog/cayhorstmann/archive/2007/12/properties_get_1.html"&gt;bad publicity&lt;/a&gt; lately. One entry was too much, so there  is: "&lt;a href="http://freddy33.blogspot.com/2008/01/wild-java-properties-road-so-far.html"&gt;Wild Java Properties, the Road so Far&lt;/a&gt;" and "&lt;a href="http://freddy33.blogspot.com/2008/01/wild-java-properties-wild-part.html"&gt;Wild Java Properties, The Wild Part&lt;/a&gt;".&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The second entry is about extension methods and how Modules and API can really benefits from them.&lt;/li&gt;&lt;li&gt;And the third is, again, about checked exceptions.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;I wanted to publish all these in one go, because I hate suspense ;-), but time is running out. So, I'll do it in steps.&lt;br /&gt;&lt;br /&gt;Anyway, the "sad" conclusion of all this work and thinking is that I bought the Scala book, and starting today, will start playing on the grass of Java neighbors. May be, it is really greener?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-1919196982089985556?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/1919196982089985556/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=1919196982089985556' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/1919196982089985556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/1919196982089985556'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2008/01/java-wild-series.html' title='The Java Wild series!'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-6015487384253179921</id><published>2007-11-12T20:14:00.000+02:00</published><updated>2007-11-13T00:19:56.703+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='openjdk'/><title type='text'>The Ugly Duckling of Java!</title><content type='html'>It took me time to find a good title. It could have been things like:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;What's so ugly about explicit type parameters?&lt;/li&gt;&lt;li&gt;Done with inference!&lt;/li&gt;&lt;li&gt;Let's pave the way for reification and promote explicit type parameters!&lt;/li&gt;&lt;/ul&gt;Chaotic java already made a similar point: &lt;a href="http://chaoticjava.com/posts/can-someone-please-explain-type-inference-to-me/"&gt;Can someone please explain type inference to me?&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;But all these compiler language terms, are showing off for no reason. The problem is not so complicated, but the stakes are high. Like Eric Burke says in his blog &lt;a href="http://stuffthathappens.com/blog/2007/11/07/a-syntax-trick-i-was-not-aware-of/"&gt;A Syntax Trick I Was Not Aware Of&lt;/a&gt;, there is a syntax in Java that very few people use and encounter: Explicit type arguments or parameters. One of the rare places where you may have encountered it, is in the JLS and javac code and test code. So, it looks like:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;List&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;empty &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Collections.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255); font-style: italic;"&gt;emptyList(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;/span&gt;&lt;/pre&gt;The first reaction, for most Java developers, is: WTF?!&lt;br /&gt;&lt;br /&gt;But I remember the first time I started converting some 1.4 code to use generics and wrote:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Map&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Integer,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Map&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String,Thing&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;messages;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;/span&gt;&lt;/pre&gt;Wow, that's a lot of &amp;lt;&amp;gt;! And when I saw the amount of bugs the compiler gave me (wrong casting and objects in put()), I really thanked the &amp;lt;&amp;gt;, and asked for more ;-)&lt;br /&gt;&lt;br /&gt;Why, the Java compiler wants to hide &amp;lt;&amp;gt; of explicit type parameter?&lt;br /&gt;On IntelliJ the &amp;lt;String&amp;gt; before the emptyList method, is underlined with the remark: Explicit type arguments can be inferred. Basically, it means the compiler can be smart enough to replace the content of &lt;&gt; with the correct type. Great, at first. But wait?&lt;br /&gt;Like Stephan says in &lt;a href="http://stephan.reposita.org/archives/2007/11/05/explicit-static-types-are-not-for-the-compiler-but-for-the-developer-duh/"&gt;Explicit Static Types are not for the Compiler, but for the Developer - Duh&lt;/a&gt;, the compiler knows a lot more stuff. He can remove a lot of all this types we are writing.&lt;br /&gt;I love strongly type Java, and all the types repetition. I love the types in the code because it's more readable.&lt;br /&gt;&lt;br /&gt;Question: Why explicit type parameters are an exception?&lt;br /&gt;Answer: It got the Ugly Duckling stamp for some reason! Some said that it was dangerous for kittens!&lt;br /&gt;&lt;br /&gt;Personally, I think there are 2 reasons:&lt;br /&gt;- When Java 5 came out it looked like too much &amp;lt;&amp;gt; all over and Sun tried to remove some unneeded ones.&lt;br /&gt;- It lacks consistency. I would really like to know, why explicit type parameters are declared BEFORE the method name? When, in constructor and type declaration, they are declared AFTER. In the later, they are enforced, and everybody is using them!&lt;br /&gt;&lt;br /&gt;Another worrying inconsistency that may appear in Java 7 is around the "Short instance creation" issue. For example the nicest proposal so far is Neal's &lt;a href="http://gafter.blogspot.com/2007/07/constructor-type-inference.html"&gt;constructor type inference&lt;/a&gt;. I really like this proposal because it enables inference to work, but you SEE it working. It's not hidden woodoo compiler stuff. According to this proposal instead of:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;List&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;list &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; ArrayList&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;();&lt;/span&gt;&lt;/pre&gt;you'd write:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;List&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; list = &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; ArrayList&amp;lt;&amp;gt;();&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;Again, a strange sense of peculiarity for the method emptyList. In the &lt;a href="http://tech.puredanger.com/java7#typeinference"&gt;type inference&lt;/a&gt; block of Alex Miller Java 7 page, you see the peculiar treatment of methods compare to types.&lt;br /&gt;Why nobody wants:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;List&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; empty = Collections.&amp;lt;&amp;gt;emptyList();&lt;/span&gt;&lt;/pre&gt;It's the same, no? Let's be consistent!&lt;br /&gt;&lt;br /&gt;Now, the main big issue that I have with this inference vs. explicit issue, is that it's moving Java away from reification of generics. It's going in the wrong direction. I just refactored some JPA code from:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255); font-style: italic;"&gt;// The Class of the bean implementaion provided by&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255); font-style: italic;"&gt;// the framework and unknown to the client&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Class &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;implClass = ...;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;MyBeanInterface &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;b &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= (&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;MyBeanInterface)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;em.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;find(&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;implClass,pk)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt; &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;to&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;MyBeanInterface &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;b &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;em.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;MyBeanInterface&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;find(&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;implClass,pk)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;/span&gt;&lt;/pre&gt;It may be just changing casting to generics. But that's the point of generics being way nicer and more powerful.&lt;br /&gt;&lt;br /&gt;The other point is, when generics will be reified I'd be closer to the perfect methods:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;MyBeanInterface &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;b = &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;em.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;MyBeanInterface&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;find(&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;pk)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;or with VISIBLE type inference&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;MyBeanInterface &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;b = &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;em.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;&amp;lt;&amp;gt;find(&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;pk)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt; &lt;/span&gt;&lt;/pre&gt;These methods will find the implementation from the interface. Exactly what I need, the client code doesn't know about the implementation class, and the code is very clean and readable.&lt;br /&gt;&lt;br /&gt;Today, because of erasure, in most methods (80%) that use generic types, you end up having Class&amp;lt;T&amp;gt; or Collection&amp;lt;T&amp;gt; as a parameter. So, inference works most of the time, and it's saving us from having to visualize the Ugly Duckling. For sure, it worked.&lt;br /&gt;&lt;br /&gt;Now, for the 20% that still resist the roman empire of javac guru inference power, a new wave is coming. They want to write a "smarter" javac, that will make inference work (Check Kevin Bourrillion and Bob Lee comments &lt;a href="http://stuffthathappens.com/blog/2007/11/07/a-syntax-trick-i-was-not-aware-of/"&gt;here&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;Here, there is a shift in the javac thinking, and it's going against readability, since: The "smarter" (or magical) the compiler is, the less "readable" your code is. Furthermore, inference will never be (by definition) 100% sure. So, why bother? The final code is more readable anyway...&lt;br /&gt;&lt;br /&gt;IMHO: The kittens are safe, and reifying generics is more important than inference.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-6015487384253179921?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/6015487384253179921/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=6015487384253179921' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/6015487384253179921'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/6015487384253179921'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2007/11/ugly-duckling-of-java.html' title='The Ugly Duckling of Java!'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-3993327313957528742</id><published>2007-11-08T19:00:00.000+02:00</published><updated>2007-11-08T09:26:32.429+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='jcp'/><category scheme='http://www.blogger.com/atom/ns#' term='jsf'/><title type='text'>Is JSF following EJB road?</title><content type='html'>First I have to be clear: I don't like JSF!&lt;br /&gt;&lt;br /&gt;But, I did not like EJB 1.0 when it came out. And still, I did bet on it's success.&lt;br /&gt;&lt;br /&gt;When EJB 1.0 came out I just finished my personal implementation of a CORBA Application Server, so this new Specification was "way below" my stuff. I was young, but still you cannot stop the machine coming from Sun, BEA and after quite some time IBM.&lt;br /&gt;EJB came in a world were crazy techies (like me) thought they can build great servers which can handle enormous load. So, this specification really calm down crazy development and provided a good base for containers (usage and implementation).&lt;br /&gt;But, it was flawed, right from the beginning.&lt;br /&gt;All the API, interfaces and design concentrated on showing off the "great" power of the Application Server. Look how I can passivate/activate, look I can do security and transaction, and look I even save in DB for you. And for every "look" as a poor developer you needed to answer (implement, declare) something.&lt;br /&gt;There was no escape, your code was full of unwanted pollution.&lt;br /&gt;EJB 2.0 did not solve the problem and actually added more "look" at my beautiful AS: Messaging and CMP.&lt;br /&gt;&lt;br /&gt;We had to wait for JBoss guys to take over EJB specification for 3.0, to finally end the developer nightmare.&lt;br /&gt;&lt;br /&gt;And now, the funny trick. Please replace in the above EJB with JSF...&lt;br /&gt;Amazing, it fits.&lt;br /&gt;&lt;br /&gt;JSF came when Web UI was a total mess (All Struts usage override most configuration and basic classes) and everyone had his own "best/better" implementation.&lt;br /&gt;So, JSF did some clean up in Web UI design and implementation.&lt;br /&gt;But, JSF is really "showing off": Look my nice lifecycle in 42 steps, Look my nice big list of jsp tags/attributes, Look my nice EL, Look my nice XML configuration, and so on.&lt;br /&gt;By "showing off" I mean that you need to fill all this with a lot of unreadable and incomprehensible repetition. And the worst of it you need to master all this in order to:&lt;br /&gt;- debug correctly,&lt;br /&gt;- integrate external stuff (Ajax4JSF and so on),&lt;br /&gt;- create just one JSF UI component (Does someone sells T-shirt with: I wrote my JSF component! without breaking the lifecycle?),&lt;br /&gt;- write stupid HTML pages.&lt;br /&gt;&lt;br /&gt;A really good description of all JSF flaws are listed in Gavin blog: &lt;a href="http://in.relation.to/Bloggers/Everyone/Tag/EE6+Wishlist"&gt;EE6 Wichlist&lt;/a&gt;&lt;br /&gt;In this blog entries, the first one on EJB the second on JSF, looking quickly at the code examples you understand the gap. EJB is full of nice Annotations and Meta Annotations (the future for sure), and JSF full of ugly XML and Expression Language (scheduled to die).&lt;br /&gt;&lt;br /&gt;The biggest conceptual flaw of JSF is the usage of EL.&lt;br /&gt;EL is breaking encapsulation, in term of IoC: it's on the wrong side of the road. Ophir pointed me to a nice essay from Terence Parr "&lt;a href="http://www.cs.usfca.edu/%7Eparrt/papers/mvc.templates.pdf" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"&gt;Enforcing Strict Model-View Separation in Template Engines &lt;/a&gt;", that really nicely proves my point.&lt;br /&gt;A UI definition (Web page, Swing panel, ...) should not know about the object graph. If I am a UI designer, I'm not a business modeler.&lt;br /&gt;The answer is in architecture like Wicket and JSR-295 (The EL in this Beans Binding is due to the lack of property support).&lt;br /&gt;In these good architecture: The UI components have an ID related to the page/panel, and the Java developers bind data to these components and receive events from these components. This is the good way to do UI, integrate UI design and manage UI logic. From experience, it works great.&lt;br /&gt;&lt;br /&gt;All the other flaws are due to the age of JSF and the fact that it was written for ugly request/response Web UI behavior.&lt;br /&gt;&lt;br /&gt;So JSF is today at the stage of EJB 1.0, I can see JSF 2.0 pushing more in the wrong direction, and so having finally a JSF 3.0 were developers will stop having nervous shake when they hear: JSF!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-3993327313957528742?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/3993327313957528742/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=3993327313957528742' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/3993327313957528742'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/3993327313957528742'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2007/10/is-jsf-following-ejb-road.html' title='Is JSF following EJB road?'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-3881666769631787126</id><published>2007-11-02T16:43:00.001+02:00</published><updated>2007-11-07T18:05:42.467+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='abstract enum'/><category scheme='http://www.blogger.com/atom/ns#' term='jpa'/><category scheme='http://www.blogger.com/atom/ns#' term='openjdk'/><title type='text'>Playing with the full abstract enum!</title><content type='html'>Since Neal Gafter released the &lt;a href="http://gafter.blogspot.com/2007/10/java-closures-first-prototype.html"&gt;closure prototype&lt;/a&gt;, Ricky Clarkson has been having a lot of fun. He wrote 2 nice blogs:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://rickyclarkson.blogspot.com/2007/10/java-7-example-pattern-matching.html"&gt;Java 7 Example - Pattern Matching&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://rickyclarkson.blogspot.com/2007/11/java-7-example-writing-your-own-foreach.html"&gt;Java 7 Example - Writing Your Own Foreach&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;Both have "Java 7 Example" in their titles - So closures is going in Java 7: Got that!&lt;br /&gt;&lt;br /&gt;The Java code is a little scary at first, but after a while it works, you can read it. IMHO: all the inlining of closure syntax can get very confusing. I know they supposed to be, but I played with the code and when you create variables for the closures it helps increased readability.&lt;br /&gt;&lt;br /&gt;Anyway, I really like the fact that you can now really test, today,  closures and their impact on your code.&lt;br /&gt;All this, gave me the idea to do the same for abstract enum.&lt;br /&gt;&lt;br /&gt;The reasons for abstract enum (and there are more I'm sure) are:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;I wanted abstract enum for solving the property binding issue in a type safe way.&lt;/li&gt;&lt;li&gt;I found out that you cannot use String Enum.name() and int Enum.ordinal() methods as annotations parameters.&lt;/li&gt;&lt;li&gt;I know there are way too many strings in annotations (methods, fields, scopes, states, package, groups, ...). I don't like strings describing my code.&lt;/li&gt;&lt;li&gt;While I was at it, &lt;a href="http://forums.java.net/jive/thread.jspa?threadID=26751&amp;amp;tstart=15"&gt;Steven Coco&lt;/a&gt; asked for generics in enums, so it's there also. That happens to be quite an interesting feature, that was already there from Neal (but buggy ;-).&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;For all those reasons I know abstract enum is a good thing. Changing the javac to implement this feature is at least 2 orders of magnitude easier than implementing closures, so it was within my reach ;-)&lt;br /&gt;&lt;br /&gt;I have exposed some mercurial repositories for &lt;a href="http://www.jfrog.org/hg/openJDK/MASTER/langtools/"&gt;langtools&lt;/a&gt; and for the &lt;a href="http://www.jfrog.org/hg/openJDK/MASTER/jdk/"&gt;jdk&lt;/a&gt;. You need to have a mercurial working copy of openJDK, then inside langtools run:&lt;br /&gt;hg pull http://www.jfrog.org/hg/openJDK/MASTER/langtools&lt;br /&gt;&lt;br /&gt;You can "hg log" to see what's going on, then do:&lt;br /&gt;hg up&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://www.jfrog.org/hg/openJDK/MASTER/jdk/rev/4ed0e928e970"&gt;patch&lt;/a&gt; for the JDK is very small, and actually (in my view), it is just another valid way (in a Java 5 environment) to do Class.isEnum() and Annotations parsing. The new JDK is needed for the tests to pass because abstract enum are not considered enum by java.lang.Class otherwise :-(.&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Type safe reflection&lt;/h4&gt;&lt;br /&gt;The solution for field binding is straight forward. The abstract enum looks like:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;abstract&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;enum&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; FieldDefinition {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; Field reflectField;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; Field getField() {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; (reflectField == &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;) {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            Class modelClass = &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;try&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;                modelClass = &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;this&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;.getClass().getEnclosingClass();&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;                reflectField = modelClass.getDeclaredField(name());&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            } &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;catch&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; (NoSuchFieldException e) {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;                &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;throw&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; ObjectMappingException(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"Field "&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; + &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;this&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; +&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;                        &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;" does not exists in "&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; + modelClass, e);&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            }&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        }&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; reflectField;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;/span&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And to use it in my Value Object it looks like:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;&lt;span style="font-family:monospace;"&gt;p&lt;/span&gt;ublic&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ModelMock &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;firstName;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;lastName;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;age;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;static&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;enum&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;fields &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;extends&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;FieldDefinition &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;firstName,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;lastName,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;age;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;Of course is not as good as properties as a language support, but it solves my problem. From the above, I extended to property using generics. So, the PropertyDefinition takes the property type as generic parameter, so the generic getter/setter methods are generic typed. I took (type 1 and 2) from Stephen Colebourne's Weblog &lt;a href="http://www.jroller.com/scolebourne/entry/java_7_properties_terminology"&gt;&lt;b&gt;Java 7 - Properties terminology&lt;/b&gt;&lt;/a&gt;, and converted it.&lt;br /&gt;&lt;br /&gt;Before abstract enum there was:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;MyBeanBefore &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;firstName;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;lastName;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;BigDecimal &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;height;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Date &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;dob;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;PropertyDefinition&amp;lt;MyBeanBefore,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; firstNameProperty() {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;      &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; ReflectionAttachedProperty.create(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;this&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"firstName"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;PropertyDefinition&amp;lt;MyBeanBefore,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; lastNameProperty() {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;      &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; ReflectionAttachedProperty.create(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;this&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"lastName"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;PropertyDefinition&amp;lt;MyBeanBefore,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;BigDecimal&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; heightProperty() {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;      &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; ReflectionAttachedProperty.create(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;this&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"height"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;PropertyDefinition&amp;lt;MyBeanBefore,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Date&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; dobProperty() {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;      &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; ReflectionAttachedProperty.create(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;this&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"dob"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;always using strings :-( And now:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@FieldPrefix(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"_"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;MyBean &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;_firstName;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;_lastName;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;BigDecimal &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;_height;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Date &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;_dob;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;static&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;enum&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;properties&amp;lt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;V&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;extends&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;PropertyDefinition&amp;lt;MyBean,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;V&amp;gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &amp;lt;String&amp;gt; firstName,&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &amp;lt;String&amp;gt; lastName,&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &amp;lt;BigDecimal&amp;gt; height,&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &amp;lt;Date&amp;gt; dob&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;This code actually compile and run (with the strange _ prefix ;-). Cool, no. The full code is under subversion &lt;a href="https://www.jfrog.org/svn-jfrog/abstract-enum/fields-enum"&gt;here&lt;/a&gt;.&lt;br /&gt;Now, with this, I can find usages, refactor, and get compilation errors for every binding using a field that does not exist. Like in here:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;MyBean &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;bean &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;MyBean(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;PropertyAdaptor&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;MyBean,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Date&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; dobProperty = MyBean.properties.dob;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;PropertyInstance&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Date&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;dobPropertyInstance &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;dobProperty.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;getPropertyInstance(&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;bean)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;The type safety is not entirely true, since in my own Model class I get Runtime error for mismatching fields in the "fields" enumeration. This can be solve in 2 ways: make fields a keyword in Java and generate it automatically ;-), and/or test your model class and fields enumeration correctly.&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;abstract enum in Annotations&lt;/h4&gt;&lt;br /&gt;Like with closures, today when I encounter a problem in some projects, I often end up with: That will have been a lot faster and nicer with closures, and that will be solved perfectly with abstract enum. Now, I know it's the standard disease of being too much into it ;) But still I think it's true.&lt;br /&gt;&lt;br /&gt;And abstract enum in Annotations is, for me, a really powerful feature.&lt;br /&gt;&lt;br /&gt;So, one problem I had was with JPA schema names, cache names, and fields associations. All those information need to be provided as strings inside annotations. And of course they are repeating themselves a lot, they get misspelled, and basically you loose the strong typing.&lt;br /&gt;So, I wanted to use enum (Schemas, Caches, Fields) to control the strings. But I would hit a dead end: Enum.name() is not a string literal, so you cannot use it in Annotations.&lt;br /&gt;Now, with abstract enum, I have way more flexibility and type safety.&lt;br /&gt;For the caches for example I can have Hibernate declaring something like:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;abstract&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;enum&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;CacheDefinition &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;CacheConcurrencyStrategy &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;defaultUsage;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;defaultInclude;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    CacheDefinition(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;CacheConcurrencyStrategy &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;defaultUsage,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;defaultInclude)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;this&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;defaultUsage &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;defaultUsage;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;this&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;defaultInclude &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;defaultInclude;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;CacheConcurrencyStrategy &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;getDefaultUsage() {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;defaultUsage;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;getDefaultInclude() {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;defaultInclude;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt; &lt;/span&gt;&lt;/pre&gt;and then in my application:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;enum&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;MyCaches &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;extends&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;CacheDefinition &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;references(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;CacheConcurrencyStrategy.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;READ_ONLY,&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"all"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;),&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;business(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;CacheConcurrencyStrategy.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;TRANSACTIONAL,&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"non-lazy"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;to use in:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@Cache(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;MyCaches.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;business)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Action &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    ...&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I wrote a blog (&lt;a href="http://freddy33.blogspot.com/2007/07/jpa-namedqueries-and-jdbc-40.html"&gt;JPA NamedQueries and JDBC 4.0&lt;/a&gt;) about how to solve the string association issue in JPA named queries.  Frank Cornelis &lt;a href="http://cup-of-java.blogspot.com/2007/08/java-ee-6-wishlist-continued.html"&gt;answered&lt;/a&gt; with an addition that enables the reuse of query methods. The main problem with this addition is it adds more strings in annotations.&lt;br /&gt;This case can also be solved with abstract enum.&lt;br /&gt;&lt;br /&gt;So, if you reached there and you like the language feature of abstract enum: Vote for the RFE: &lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6570766"&gt;6570766&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-3881666769631787126?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/3881666769631787126/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=3881666769631787126' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/3881666769631787126'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/3881666769631787126'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2007/11/abstract-enum-ricky-carlson-way.html' title='Playing with the full abstract enum!'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-3576221323633724859</id><published>2007-10-28T14:42:00.000+02:00</published><updated>2007-11-03T11:23:42.204+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='webbeans'/><category scheme='http://www.blogger.com/atom/ns#' term='jcp'/><category scheme='http://www.blogger.com/atom/ns#' term='architecture'/><title type='text'>Web Beans and Modules!</title><content type='html'>After some good work, the JSR-299 group released an early draft, first published on &lt;a href="http://in.relation.to/Bloggers/JSR299WebBeansEarlyDraft"&gt;Gavin King's blog&lt;/a&gt;, and now on the &lt;a href="http://jcp.org/aboutJava/communityprocess/edr/jsr299/"&gt;JCP site&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://in.relation.to/Bloggers/TheWebBeansManifesto"&gt;spirit of Web Beans&lt;/a&gt; is really good, and the way the annotations came out is very promising. I have nothing to say but compliment the Component Types, Component Bindings, Scopes, Injection, and Interceptors. The Event has the good approach (Event type filter), but looks young at the moment.&lt;br /&gt;&lt;br /&gt;Web Beans is really the state of the art "Educational Framework". The technical base is already explored (Guice, Spring, Seam) and is not so complex, but the impact on the developer thinking is really significant. Like every good "Educational Framework" (Struts, Spring, Seam), it makes it harder to do the "bad thing" (hacking, ugly coupling) than the right one (framework driven injection and loose coupling).&lt;br /&gt;I know that if developers start to use these Annotations their code will get cleaner, more readable and manageable.&lt;br /&gt;&lt;br /&gt;But, reading through the specs and especially, "4.4.2 Interceptors bindings" and "8. Packaging and configuration", I felt like something was wrong: Where are my Web Beans modules?&lt;br /&gt;I don't want to get into the argument of OSGi or JSR-277, but I was expecting a more modular approach of Web Beans Injection.&lt;br /&gt;What I mean, is that I would like to see a Web Beans "core" defining all the above Annotations for a pure J2SE environment. This would be the specification of how to use Dependency Injection Annotations. On top of that, another specification on how to provide "Components Provider/Injectors" for JEE, JSF, EJB, MDB and so on.&lt;br /&gt;For example, I want to be able to do:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@Log&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Logger &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;log;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;just by adding log4j-web-beans.jar in my classpath. In this jar Log4J will provide the Web Beans Component for my class and my environment.&lt;br /&gt;So, with this approach all the EJB, JSF &amp;amp; JEE stuff that really don't have to be there, can be specified separately as: jee5-web-beans.jar, ejb-web-beans.jar, mdb-web-beans.jar, etc.&lt;br /&gt;I think it will make the specifications easier to read and a lot more flexible for all the great future components ;-)&lt;br /&gt;&lt;br /&gt;Since I don't like people that complain without proposing something of their own, I tried to see how to do this with the current specification. And, basically it's not missing much.&lt;br /&gt;Today in EJB3 environment, the first thing I do is creating an Interceptor that can inject components from Spring or other sources in my Session Beans. The injection is based on my project level Annotations and it bridges Spring and EJB3 nicely.&lt;br /&gt;So a first solution (not good but...) is to use javax.interceptor.InvocationContext. If the Web Beans container is adding some entry in getContextData(), I can find out the Component Type, the Scope, and other information and decide how to populate all the @Log fields.&lt;br /&gt;&lt;br /&gt;A nicer solution will be to have Annotations specified by JSR-299, that will allow me to write something like:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@ComponentProvider&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Jee5ComponentProvider &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@Provides(EJB.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Object &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;getEJB(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;WebBeansContext &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;wbc)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;try&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; InitialContext().lookup(&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;                wbc.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;getDestinationField().getType().getName());&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        } &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;catch&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; (&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;NamingException &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;e)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;e.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;printStackTrace();&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;throw&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; RuntimeException(&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;e)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        }&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;Here I really did not investigate enough, but I know I'm missing @ComponentProvider and WebBeansContext in the current specification.&lt;br /&gt;What do you think?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-3576221323633724859?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/3576221323633724859/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=3576221323633724859' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/3576221323633724859'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/3576221323633724859'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2007/10/web-beans-and-modules.html' title='Web Beans and Modules!'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-4446356454140372250</id><published>2007-10-17T20:34:00.000+02:00</published><updated>2007-10-30T00:02:17.125+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='webbeans'/><category scheme='http://www.blogger.com/atom/ns#' term='jcp'/><title type='text'>JSR-299 or Web Beans</title><content type='html'>After postponing for too long, I finally decided to look at &lt;a href="http://jcp.org/en/jsr/detail?id=299"&gt;Web Beans&lt;/a&gt; or JSR-299.&lt;br /&gt;&lt;br /&gt;The story is that for our seminar &lt;a href="http://www.pc.co.il/Index.asp?CategoryID=82&amp;amp;ArticleID=649"&gt;JavaEdge 2007&lt;/a&gt; we invited Gavin King. He accepted to come and to talk about his new JSR, and this was the first time I encountered &lt;span style="font-weight: bold;"&gt;"Web Beans"&lt;/span&gt;.&lt;br /&gt;And to tell the truth: The name gave me a cold shower ;-)&lt;br /&gt;What? Gavin started as a backend guru for O/R Mapping, then decided to target the issue of Web development with Seam, and now is "may be" going even higher in the stack with some UI components spec!&lt;br /&gt;It really sounded like Gavin was leading the new spec for some JSF UI widgets :-(&lt;br /&gt;&lt;br /&gt;This name really put me off, and so I postponed reading about "Web Beans".&lt;br /&gt;That was a mistake, and a really bad move.&lt;br /&gt;&lt;br /&gt;When I saw in Gavin &lt;a href="http://in.relation.to/2570.lace"&gt;blog&lt;/a&gt;, that he was excited about exposing the work done in JSR-299 group, I decided to get into it.&lt;br /&gt;&lt;br /&gt;And the conclusion is:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;From my personal technical glossary, "Web Beans" has nothing to do with Web, and Beans are not UI JavaBeans.&lt;/li&gt;&lt;li&gt;Gavin did it again.&lt;/li&gt;&lt;/ol&gt;Before Hibernate the O/R Mapping tools concentrated more on showing off their feature list than helping developer having a persistent model. For Gavin what's important is how the user (poor developer) will communicate with the framework. Powerful features should not show off and complicate the API or the tool. Once the usage is clear, the framework follows.&lt;br /&gt;So after Seam and easy @Conversation, he's leading this great JSR.&lt;br /&gt;&lt;br /&gt;"Web Beans" is basically a good (meaning pushing forward) standardization of IoC and DI concepts using Annotations. The overview from &lt;a href="http://in.relation.to/2595.lace"&gt;Gavin slides of the Silicon Valley JUG&lt;/a&gt;, is a really good start to understand what JSR-299 is about.&lt;br /&gt;&lt;br /&gt;"Web Beans" really uses the good Guice framework, removes the issue of static scopes in Seam, and helps you create your own meaningful project Annotations. And all this is done true to the Java spirit: in a readable way.&lt;br /&gt;JSR-299 answers some of my needs I had in &lt;a href="http://freddy33.blogspot.com/2006/01/mda-is-dead-long-live-aada.html"&gt;AADA&lt;/a&gt; and I hope it will help projects moving towards creation of more custom Annotations.&lt;br /&gt;&lt;br /&gt;So, please, change the name...&lt;br /&gt;&lt;ul&gt;&lt;li&gt;First, for once the JSR number is very easy to remember ( 300 - 1 easy to find an association).&lt;/li&gt;&lt;li&gt;Second I always associated &lt;span style="font-weight: bold;"&gt;Beans&lt;/span&gt; with &lt;span style="font-weight: bold;"&gt;JavaBeans&lt;/span&gt; Swing UI or Struts, and I never felt it was connected with the concept of &lt;span style="font-weight: bold;"&gt;Components&lt;/span&gt; used in Spring, Guice, Seam or JSR-299. By the way, in "Web Beans" there is no @Bean but only @Component.&lt;/li&gt;&lt;li&gt;Third, I found the term API (Application Programming Interface) does not match today's specification code and technique. EJB3, JAXWS and so on don't export a DLL API. They help you code. For example, In JPA (&lt;a href="http://jcp.org/en/jsr/detail?id=317"&gt;Java Persistence API&lt;/a&gt;) more than 90% of the code are Annotations not Interfaces. It should be Java Persistence Annotations, no? You can argue that Annotations are indeed interfaces in Java, and that it will not change the acronym ;-)&lt;/li&gt;&lt;/ul&gt;Anyway here are 2 possible names:&lt;br /&gt;- Dependency Injection API (or Annotations)&lt;br /&gt;- Components Injection API (or Java Components Injection Annotations ;-)&lt;br /&gt;&lt;br /&gt;Finally, JSR-299 DIA also generalizes the concept of Injector injected by injection from the Dependency Injection framework, and I'm really happy about it ;-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-4446356454140372250?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/4446356454140372250/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=4446356454140372250' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/4446356454140372250'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/4446356454140372250'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2007/10/jsr-299-or-web-beans.html' title='JSR-299 or Web Beans'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-1742821256331887914</id><published>2007-08-01T00:26:00.001+03:00</published><updated>2008-09-28T14:59:04.323+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='jpa'/><title type='text'>JPA NamedQueries and JDBC 4.0</title><content type='html'>In one project doing a migration from EJB 2.0 to EJB 3, I found this:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@Entity(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;name = &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"Action"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@NamedQueries(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@NamedQuery(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;name = &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"Action.findAll"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;, query = &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"SELECT o FROM Action o"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;),&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@NamedQuery(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;name = &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"Action.findByExtCode"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;, query = &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"SELECT o FROM Action o WHERE o.externalCode = ?1"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;),&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@NamedQuery(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;name = &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"Action.findByDescription"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;, query = &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"SELECT o FROM Action o WHERE o.description = ?1"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;),&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@NamedQuery(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;name = &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"Action.findManualActions"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;, query = &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"SELECT o FROM Action o WHERE o.manual=?1"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;),&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@NamedQuery(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;name = &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"Action.findSelectedActions"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;, query = &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"SELECT o FROM Action o WHERE o.actionType.id &amp;lt;&amp;gt; 3"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;),&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@NamedQuery(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;name = &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"Action.findFlowActions"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;, query = &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"SELECT o FROM Action o WHERE o.actionType.id=3"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;),&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@NamedQuery(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;name = &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"Action.findByActionFlowId"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;, query = &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"SELECT o FROM Action o JOIN o.actionFlows af WHERE af.id = ?1"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;)&lt;br /&gt;})&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;The code looks like this, because when doing named queries in JPA the name need to be unique for the WHOLE persistence unit. So, we agreed about the naming convention "[entity name].[finder name]" for the name of the query.&lt;br /&gt;It is actually quite nicer an more manageable than EJBQL in xml files, but still there is quite a bunch of copy/paste, String that are not constants, and the usage of named queries is here more problematic than EJB 2.0 home interfaces.&lt;br /&gt;The usage looks like:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Query &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;namedQuery &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;em.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;createNamedQuery(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"Action.findByExtCode"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;namedQuery.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;setParameter(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(255, 255, 255);"&gt;1&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"001"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ActionBean &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;actionBean &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= (&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ActionBean)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;namedQuery.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;getSingleResult();&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;And this is for only one parameter...&lt;br /&gt;&lt;br /&gt;The possible code errors (due to lack of static typing) we get here are:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Errors on the string name for the namedQuery&lt;/li&gt;&lt;li&gt;Errors on the parameter position (the named queries annotation is in the model not close to the business logic executing queries)&lt;/li&gt;&lt;li&gt;Errors in Casting&lt;/li&gt;&lt;/ol&gt;So, when looking at this, I thought about &lt;a href="http://jcp.org/aboutJava/communityprocess/edr/jsr221/index2.html"&gt;JDBC 4.0&lt;/a&gt; (jsr 221 chapter 20 of the spec) and finally managed to create a nice &lt;a href="http://www.jfrog.org/viewvc/jfrog/greenhouse/jpa/trunk/src/main/java/org/jfrog/greenhouse/jpa/framework/NamedQueryDynamicProxy.java?view=markup"&gt;dynamic proxy&lt;/a&gt; doing the work for JPA.&lt;br /&gt;It is quite clear looking at the code above, a JPA named query can be defined as an interface method. It has:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;a name (entityName + methodName),&lt;/li&gt;&lt;li&gt;a list of parameters (ordered or named),&lt;/li&gt;&lt;li&gt;and a result (list or single).&lt;/li&gt;&lt;/ul&gt;So, with the dynamic proxy the usage code looks like:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ActionQuery &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;actionQuery &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;NamedQueriesFactory.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255); font-style: italic;"&gt;getQueryProxy(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ActionQuery.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;em)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ActionBean &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;action = &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;actionQuery.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;findByExtCode(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"001"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;And the Queries interface:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@JpaQueriesInterface(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;prefix = &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"Action"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;interface&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ActionQuery &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Collection&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ActionBean&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; findAll();&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ActionBean &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;findByExtCode(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;extCode)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@JpaQueryUseParamNames&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ActionBean &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;findByDescription(&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@JpaParamName(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"description"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;description)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Collection&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ActionBean&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; findManualActions(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;boolean&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;manual)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Collection&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ActionBean&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; findSelectedActions();&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Collection&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ActionBean&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; findFlowActions();&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Collection&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ActionBean&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; findByFlowActionId(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;long&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;flowActionId)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;Which gets all the advantage of strong Java typing.&lt;br /&gt;So, the code of my small running example is here:&lt;br /&gt;&lt;a href="http://subversion.jfrog.org/jfrog/greenhouse/jpa/trunk/"&gt;http://subversion.jfrog.org/jfrog/greenhouse/jpa/trunk/&lt;/a&gt; and it's using maven of course...&lt;br /&gt;Now, the next step is to use the Annotated Query Interface has NamedQuery provider so it will really look like JDBC 4.0.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-1742821256331887914?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/1742821256331887914/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=1742821256331887914' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/1742821256331887914'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/1742821256331887914'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2007/07/jpa-namedqueries-and-jdbc-40.html' title='JPA NamedQueries and JDBC 4.0'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-624399231867978472</id><published>2007-07-14T09:56:00.000+03:00</published><updated>2007-08-01T01:19:46.702+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='sun'/><category scheme='http://www.blogger.com/atom/ns#' term='openjdk'/><title type='text'>The need for RAE</title><content type='html'>With all the discussions around language changes in Java7, there is a need for democratic vote on what should be included or not.&lt;br /&gt;But in today's &lt;a href="http://bugs.sun.com/bugdatabase/index.jsp"&gt;Bug Database&lt;/a&gt; of Sun you can only vote &lt;span style="font-weight: bold;"&gt;for&lt;/span&gt; a RFE (Request For Enhancements), you cannot vote &lt;span style="font-weight: bold;"&gt;against&lt;/span&gt;. And when you look inside the &lt;a href="http://bugs.sun.com/bugdatabase/top25_rfes.do"&gt;Top 25 RFEs&lt;/a&gt; you can see that there is big controversy on most of them, and that Sun act as a final "benevolent dictator".&lt;br /&gt;For example here is an extract of the top 25 RFEs that may have an impact on Java7/OpenJDK and the language:&lt;br /&gt;&lt;table border="0" cellspacing="0" cols="3" frame="void" rules="none"&gt;  &lt;colgroup&gt;&lt;col width="54"&gt;&lt;col width="86"&gt;&lt;col width="541"&gt;&lt;/colgroup&gt;  &lt;tbody&gt;   &lt;tr&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left" height="17" width="54"&gt;&lt;b&gt;Votes&lt;/b&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left" width="86"&gt;&lt;b&gt;Bug ID &lt;/b&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left" width="541"&gt;&lt;b&gt;Synopsis&lt;/b&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" sdval="580" sdnum="1033;" align="left" height="17"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;580&lt;/span&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left"&gt;&lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4449383"&gt;4449383&lt;/a&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left"&gt;Support For 'Design by Contract', beyond "a simple assertion facility"&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" sdval="341" sdnum="1033;" align="left" height="17"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;341&lt;/span&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left"&gt;&lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4820062"&gt;4820062&lt;/a&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left"&gt;Provide "struct" syntax in the Java language&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" sdval="303" sdnum="1033;" align="left" height="17"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;303&lt;/span&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left"&gt;&lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4267080"&gt;4267080&lt;/a&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left"&gt;break up rt.jar into downloadable-on-demand components to reduce jre size&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" sdval="197" sdnum="1033;" align="left" height="17"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;197&lt;/span&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left"&gt;&lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4093687"&gt;4093687&lt;/a&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left"&gt;Extension of 'Interface' definition to include class (static) methods.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" sdval="172" sdnum="1033;" align="left" height="17"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;172&lt;/span&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left"&gt;&lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4905919"&gt;4905919&lt;/a&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left"&gt;RFE: Operator overloading&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" sdval="171" sdnum="1033;" align="left" height="17"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;171&lt;/span&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left"&gt;&lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4801527"&gt;4801527&lt;/a&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left"&gt;Support Repository in Java Web Start&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" sdval="152" sdnum="1033;" align="left" height="17"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;152&lt;/span&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left"&gt;&lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4727550"&gt;4727550&lt;/a&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left"&gt;Advanced &amp; Raw Socket Support (ICMP, ICMPv6, ping, traceroute, ...)&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" sdval="125" sdnum="1033;" align="left" height="17"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;125&lt;/span&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left"&gt;&lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4313887"&gt;4313887&lt;/a&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left"&gt;New I/O: Improved filesystem interface&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" sdval="122" sdnum="1033;" align="left" height="17"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;122&lt;/span&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left"&gt;&lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4129445"&gt;4129445&lt;/a&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left"&gt;An API to incrementally update ZIP files&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" sdval="122" sdnum="1033;" align="left" height="17"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;122&lt;/span&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left"&gt;&lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4650689"&gt;4650689&lt;/a&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left"&gt;RFE: Java needs public API for FTP&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" sdval="113" sdnum="1033;" align="left" height="17"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;113&lt;/span&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left"&gt;&lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4648386"&gt;4648386&lt;/a&gt;&lt;/td&gt;    &lt;td style="border: 1px solid rgb(0, 0, 0);" align="left"&gt;Simplify deployment and versioning by embedding JAR files within each other&lt;/td&gt;   &lt;/tr&gt;  &lt;/tbody&gt; &lt;/table&gt;&lt;br /&gt;From this list, I'm personally &lt;span style="font-weight: bold;"&gt;for&lt;/span&gt; "java kernel: 4267080", "New IO: 4313887", &lt;span style="font-weight: bold;"&gt;against&lt;/span&gt; "Operator overloading: 4905919", "Design By Contract: 4449383", and still &lt;span style="font-weight: bold;"&gt;undecided&lt;/span&gt; on "struct: 4820062".&lt;br /&gt;So, how can we compile all the votes?&lt;br /&gt;Sun needs to create RAE (Request Against Enhancements) in parallel of each controversial RFE.&lt;br /&gt;To compile the votes, we will need better access to the Bug Database, since listing all RFEs and RAEs by importance is impossible from the current Web Interface.&lt;br /&gt;The need for RAE came from the big controversy around &lt;a href="http://freddy33.blogspot.com/2007/07/voting-for-good-exception-handling.html"&gt;checked exceptions&lt;/a&gt; and I was really missing a nice compilation result of for/against.&lt;br /&gt;&lt;br /&gt;Today, Java is Open Source and the full activation of the &lt;a href="http://openjdk.java.net/groups/gb/"&gt;OpenJDK Governance Board&lt;/a&gt; is in progress. I will really like to know what to expect in the language. Having a compilation of popular RFE/RAE will help.&lt;br /&gt;But until the process of the Governance Board is not clarified, Sun position will be the decisive one. And here the current position of Danny Coward, JavaSE Platform lead, is very confusing: "Seeking a small number of changes for Java SE 7 platform" (from &lt;a href="http://developers.sun.com/learning/javaoneonline/j1sessn.jsp?sessn=TS-2383&amp;yr=2007&amp;amp;track=5"&gt;Java One presentation&lt;/a&gt;).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-624399231867978472?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/624399231867978472/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=624399231867978472' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/624399231867978472'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/624399231867978472'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2007/07/need-for-rae.html' title='The need for RAE'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-4953572809889375668</id><published>2007-07-10T21:05:00.000+03:00</published><updated>2007-08-01T01:20:35.282+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='openjdk'/><title type='text'>Voting for Good Exception Handling</title><content type='html'>&lt;div style="text-align: justify;"&gt;When getting ready for a conference I gave for Sun (&lt;a href="http://www.il.sun.com/sunnews/events/2007/javaday/pdf/track1/Java7-A.lot.to.be.waiting.for_v03.pdf"&gt;Java 7 - A lot to be waiting for&lt;/a&gt; !), I came across this blog:  &lt;a href="http://cafe.elharo.com/java/voting-for-checked-exceptions/"&gt;Voting for Checked Exceptions&lt;/a&gt;. It was in response of Neal Gafter's blog: &lt;a href="http://gafter.blogspot.com/2007/05/removing-language-features.html"&gt;Removing Language Features?&lt;/a&gt;.&lt;br /&gt;The list of comments is very long, and I never found the time to read them, until now. I really liked what went on there (except the personal attacks), and I want to try to summarize the arguments, as I view them. The arguments are also exposed in Neal's blog comments but there was a lot less arguments...&lt;br /&gt;I'm not trying to be impartial, since for me it's clear: &lt;span style="font-style: italic;"&gt;Checked Exceptions should go.&lt;/span&gt;&lt;br /&gt;Page 49 of the presentation has the bullets that summarize my view on Checked Exceptions.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;So here are the valid arguments I saw in the blog comments:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Checked Exceptions avoid the digging of what can go wrong&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;Description:&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In other languages that does not have checked exceptions, it takes a good amount of time, thinking, QA cycles, and production crashes before you know which exception types can be thrown by a specific method.&lt;br /&gt;Basically, since the API does not declare what it can throws, as a caller you need to "guess" what can happen or catch everything and try to re-throw what should not have been catch.&lt;br /&gt;&lt;/div&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;Validity:&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The point is totally valid, but for me it does not make the balance tip on either side of the checked/unchecked issue.&lt;br /&gt;Good API should declare a good throws clause list of what can happen. This is good design and OO practice. And a caller that knows what to do in case of an exception should catch them and handle them correctly. This is valid for Exceptions in general, checked or unchecked. The issue is that in Java nobody declares unchecked exceptions in the throws clause, it looks stupid. I don't know why, I think it's just a stupid habit.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Still there is a point against checked exceptions here.  As an API writer, you are "forcing" the caller to catch ALL of the "checked" exceptions declared in your throws clause. This simple fact, breaks OO, forces some design concept on the caller (where to put the exception handler and method throws clauses), and generate all the "bloat".&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Checked Exceptions helps you remember that you need to handle them&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Description:&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;During coding you encounter methods throwing exceptions and so you need to handle them at some point. So, with checked exceptions, for a certain class or module, the list of exceptions to handle is well define.&lt;br /&gt;This point was made especially when some lazy developers will ignore unchecked exceptions all together. If the compiler will not bother, exceptions are ignore.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Validity:&lt;/span&gt;&lt;br /&gt;Here the point fails on multiple accounts:&lt;br /&gt;&lt;div style="text-align: justify;"&gt;1) Forcing the catching of an exception on a lazy developer is worse than let him go along. You end up with things like:&lt;br /&gt;&lt;/div&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;try&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;o &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= getObject(&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;id)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;} &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;catch&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; (&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;PersistenceException &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;e)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255); font-style: italic;"&gt;// Should not happen I just saved it before&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div style="text-align: justify;"&gt;Which is my personal nightmare on many projects. When the code is full of these it's totally impossible to debug, understand the behavior, or move forward. It's desperate. Simply put:&lt;br /&gt;&lt;/div&gt;&lt;span style="font-style: italic;"&gt;"Empty catch block are worse than no catch at all"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;2) Listing and catching all checked exceptions does not cover your needs in exception handling. Even in Java there are unchecked exceptions, and in today's framework you have more and more of them. So exceptions will slip through anyway.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;3) Putting the error handling in the middle of the logical code is a very bad practice. You end up copy/pasting catch block all over, and if you need a small change in error handling, well... forget it.&lt;br /&gt;The error handling is a layer of your module/component/architecture, that should be transparent and decoupled from your code.&lt;br /&gt;This is the only way to make sure you are handling correctly ALL exceptions. This is the power and design in modern framework using AOP Interceptors. So, like in Spring, JBossMC, EJB3, Hibernate, you need a framework layer to catch Throwable and find out which exception handler should take care of what at which layer. Perfect, unbeatable, robust, user friendly, HA, and more.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;You don't have to handle checked exception just pass them on&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Description:&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;If inside a method you are calling a method with checked exceptions and you don't know how to handle it, just add it to your (big) list of throws clause, someone up the call stack will take care of it.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Validity:&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;This is the most non valid argument for checked exceptions, and the main reason why Java should have only unchecked exceptions.&lt;br /&gt;I don't know many projects where any developer can just add a checked exception to the signature without blinking (the same for removing one). Checked Exceptions makes API throws clause fixed for eternity. If you add, you suffer, if you remove, you're lynched...&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;So, the only way is to create non meaningful generic Super Exception class (like IOException) that every methods throws.&lt;br /&gt;Basically, this argument contradict the 2 previous ones which are a lot more valid.&lt;br /&gt;On the other hand this feature is mandatory for normal coding. Everybody agree:&lt;br /&gt;&lt;/div&gt;&lt;span style="font-style: italic;"&gt;"If you don't know what to do with an exception, don't handle it"&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;This is critical, for "robust" application, so you need to find a way to answer this argument. Here is the proof that checked exceptions are contradicting their own benefits.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Checked Exceptions are recoverable, Unchecked are bugs&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Description:&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The principle of separation between checked/unchecked is well defined by ELH:&lt;br /&gt;"as in section 8 of &lt;a href="http://www.amazon.com/exec/obidos/ISBN=0201310058/ref=nosim/cafeaulaitA"&gt;Effective Java&lt;/a&gt;. [...] checked exceptions are for unpredictable environmental conditions such as I/O errors and and XML well-formedness violations while unchecked exceptions are for program failures that should be caught during testing, such as array index out of bounds or null pointers."&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Validity:&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Classifying, and understanding what the error IS, is a critical step in good error handling. You need to send a good type of exception, for the good type of error, with the maximum amount of information (which file, to read, to write, which DB, which XML tag, ...).&lt;br /&gt;Forcing yourself to create meaningful Exception is a difficult step, but one that always pays off. Add all the parameters you can, create meaningful messages, and use the good exception class.&lt;br /&gt;But, the separation "unpredictable environmental conditions" vs. "program failures" is highly subjective, and always false once you climb one layer in your architecture. The kind of comment &lt;span style="font-style: italic;"&gt;"Should not happen I just saved it before"&lt;/span&gt; proves my point.&lt;br /&gt;Typing is good (IOException, NPE), but to enforce the global decision for all Java software ever written that IOException is an "unpredictable environmental conditions" does not make any sense.&lt;br /&gt;Furthermore, the "forcing" of handling of "unpredictable environmental conditions" generates a lot of "development by exceptions". Basically, if you know that the file may not be there, I really prefer if the developer just create a File() object and test file.exists() instead of waiting for IOException.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Experiences with Checked Exceptions&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;1) In my experience to handle correctly an exception you need a lot of infrastructure information: How to display errors to the user (Web or Fat client), How to log, How to translate (code, language), How to trap, Severity detector, transaction access, ...&lt;br /&gt;And to provide all this information to the inner logical code that need to wrap checked exceptions is a big burden for the application. Just pass the exception, my exception handler will handle it correctly.&lt;br /&gt;Since, creating an exception handler with IOC and/or AOP that has access to all the above managers, is quite easy and clean.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;2) We are doing lately a lot of migration to JPA, and more than 50% of our headaches are on checked exceptions. We found out that checked exceptions promotes indirectly the bad habit of development by exceptions:&lt;br /&gt;&lt;/div&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;try&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;o = getObject(&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;id)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;} &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;catch&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; (&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;PersistenceException &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;e)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255); font-style: italic;"&gt;// Object not found create it&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    o = create();&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div style="text-align: justify;"&gt;And changing the API signatures, removing FinderException from EJB 2.0, or the annoying CloneableException is a true nightmare.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;3) Good coding with checked exceptions is sometimes very very tedious. For example the correct management of FileInputStream.close()  and it's IOException is getting out of hand:&lt;br /&gt;&lt;/div&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;FileInputStream &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;is = &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;try&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;is = &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; FileInputStream(&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;fileName)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255); font-style: italic;"&gt;// Some work...&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;n &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= is.read();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255); font-style: italic;"&gt;// Need to close here so caller will know file in unstable state&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    is.close();&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255); font-style: italic;"&gt;// Need to set null to avoid double close&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    is = &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;} &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;catch&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; (&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;IOException &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;e)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;throw&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; PersistenceException(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"Error reading file "&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;fileName,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;e)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;} &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;finally&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; (is != &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;) {&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;try&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;      is.close();&lt;br /&gt;  } &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;catch&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; (&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;IOException &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;ignore)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;      &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255); font-style: italic;"&gt;// Well I try to close, but it does not close&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255); font-style: italic;"&gt;// SO may be I should close ;-)&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            log.debug(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"Ignoring on close of "&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;ignore)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Conclusion&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Independently, of the discussion on closures, I really hope that the compiler enforcement of catching checked exceptions will be removed in the openJDK  very soon...&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-4953572809889375668?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/4953572809889375668/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=4953572809889375668' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/4953572809889375668'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/4953572809889375668'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2007/07/voting-for-good-exception-handling.html' title='Voting for Good Exception Handling'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-6848082662197672373</id><published>2007-06-23T21:18:00.000+03:00</published><updated>2007-10-17T20:29:32.504+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='abstract enum'/><category scheme='http://www.blogger.com/atom/ns#' term='openjdk'/><title type='text'>PATCH Abstract Enum with OpenJDK</title><content type='html'>&lt;span style="font-style: italic;font-size:130%;" &gt;&lt;span style="font-weight: bold;"&gt;The full solution in OpenJDK&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Applying from KSL to OpenJDK&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;First, there are no issues (except a diff of 2 lines in the GPL license block ;-) to apply a patch from KSL to the OpenJDK project trunk checkout.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;So I applied my &lt;a href="http://freddy33.blogspot.com/2007/06/abstract-enum-on-ksl.html"&gt;KSL patch&lt;/a&gt; and I started modifying "sun/reflect/annotation/AnnotationParser.java" to retrieve the Enum.valueOf() from the parameter class type and not from the type definition. It means that in:&lt;br /&gt;&lt;/div&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@AnnoAETest(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;ae2 = &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;E21.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;one)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;first;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;where:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; @&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;interface&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;AnnoAETest &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;AbstractE2 &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;ae2();&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;the AnnotationParser was doing &lt;code&gt;Enum.valueOf(AbstractE2.class,"one")&lt;/code&gt;, but it had actually the class E21 defined, so I changed it to the good &lt;code&gt;Enum.valueOf(E21.class,"one")&lt;/code&gt;.&lt;br /&gt;So the patch is:&lt;br /&gt;&lt;pre&gt; Index: j2se/src/share/classes/sun/reflect/annotation/AnnotationParser.java&lt;br /&gt;===================================================================&lt;br /&gt;--- j2se/src/share/classes/sun/reflect/annotation/AnnotationParser.java (revision 237)&lt;br /&gt;+++ j2se/src/share/classes/sun/reflect/annotation/AnnotationParser.java (working copy)&lt;br /&gt;@@ -422,9 +422,12 @@&lt;br /&gt;             if (!enumType.getName().equals(typeName))&lt;br /&gt;             return new AnnotationTypeMismatchExceptionProxy(&lt;br /&gt;                 typeName + "." + constName);&lt;br /&gt;-        } else if (enumType != parseSig(typeName, container)) {&lt;br /&gt;-            return new AnnotationTypeMismatchExceptionProxy(&lt;br /&gt;-                typeName + "." + constName);&lt;br /&gt;+        } else {&lt;br /&gt;+            Class paramEnumType = parseSig(typeName, container);&lt;br /&gt;+            if (!enumType.isAssignableFrom(paramEnumType))&lt;br /&gt;+                return new AnnotationTypeMismatchExceptionProxy(&lt;br /&gt;+                    typeName + "." + constName);&lt;br /&gt;+            enumType = paramEnumType;&lt;br /&gt;         }&lt;br /&gt;&lt;br /&gt;         try {&lt;br /&gt;&lt;/pre&gt;Now, another issue appears, is that the complicated test to know if a class is an enum with member or an abstract enum or anonymous class is complicated and the &lt;code&gt;Class.isEnum()&lt;/code&gt; implementation was wrong.&lt;br /&gt;After changing to the following implementation to remove specialized enum (anonymous):&lt;br /&gt;&lt;pre&gt; Index: j2se/src/share/classes/java/lang/Class.java&lt;br /&gt;===================================================================&lt;br /&gt;--- j2se/src/share/classes/java/lang/Class.java (revision 237)&lt;br /&gt;+++ j2se/src/share/classes/java/lang/Class.java (working copy)&lt;br /&gt;@@ -2877,8 +2877,7 @@&lt;br /&gt;        // An enum must both directly extend java.lang.Enum and have&lt;br /&gt;        // the ENUM bit set; classes for specialized enum constants&lt;br /&gt;        // don't do the former.&lt;br /&gt;-       return (this.getModifiers() &amp; ENUM) != 0 &amp;amp;&amp;&lt;br /&gt;-       this.getSuperclass() == java.lang.Enum.class;&lt;br /&gt;+       return ((this.getModifiers() &amp; ENUM) != 0 &amp;amp;&amp; !isAnonymousClass());&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     // Fetches the factory for reflective objects&lt;br /&gt;&lt;/pre&gt;I'm getting for my following last failed test:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;AnnoAEUsage &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@AnnoAETest(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;ae2 = &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;E21.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;one)&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;   &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;first;&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;static&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; main(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String[&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;] &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;args)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;throws&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Exception &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;      &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;System.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;out.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;println(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"Is enum "&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;E21.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;.isEnum());&lt;br /&gt;      &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;E21 &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;e21 &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= Enum.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255); font-style: italic;"&gt;valueOf(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;E21.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"one"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;      &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;switch&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; (&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;e21)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;          &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;case&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;one:&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;               &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;System.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;out.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;println(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"Got 1"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;              &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;break&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;          &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;default&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;:&lt;br /&gt;              &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;System.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;err.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;println(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"No got 1"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;      }&lt;br /&gt;      &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Field &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;field &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;AnnoAEUsage.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;.getDeclaredField(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"first"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;      &lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;AnnoAETest &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;anno &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;field.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;getAnnotation(&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;AnnoAETest.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;      &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;AbstractE2 &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;ae2 &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;anno.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;ae2();&lt;br /&gt;      &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;System.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;out.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;println(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"Youpi again "&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;ae2.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;full());&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;enum&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;E21 &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;extends&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; AbstractE2 {&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;one,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;two;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;The following output:&lt;code&gt;&lt;/code&gt;&lt;pre&gt;&lt;br /&gt;JDK Build:/work/java.net/ksl.trunk$/work/java.net/openjdk.trunk/control/build/linux-amd64/j2sdk-image/bin/java -cp build/test-classes abstractEnum.annotation.AnnoAEUsage&lt;br /&gt;Is enum true&lt;br /&gt;Got 1&lt;br /&gt;Exception in thread "main" java.lang.IllegalAccessError: tried to access class abstractEnum.annotation.AbstractE2 from class $Proxy3&lt;br /&gt;       at $Proxy3.ae2(Unknown Source)&lt;br /&gt;       at abstractEnum.annotation.AnnoAEUsage.main(AnnoAEUsage.java:32)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Some more work...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Stupid isn't it&lt;/span&gt;&lt;br /&gt;Well it turn out this one is logical...&lt;br /&gt;It's related to an open bug: &lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6256803"&gt;6256803&lt;/a&gt; which is not really a bug in my view. You just need to expose public your interfaces, since the dynamic proxy implementing annotation interface is not part of the package. So my AbstractE2 abstract enum, and the E22, E21 real enums were package protected, so: IllegalAccessError.&lt;br /&gt;After making all the test classes public, it works...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The final OpenJDK Patch&lt;/span&gt;&lt;br /&gt;For the b14 of openJDK I needed to apply for my platform: &lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6567018"&gt;6567018&lt;/a&gt;&lt;br /&gt;The above patch file is for "hotspot/src/share/vm/gc_implementation/"&lt;br /&gt;&lt;br /&gt;The root project for my patches (KSL and OpenJDK) and all tests files is &lt;a href="https://www.jfrog.org/svn-jfrog/abstract-enum/"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;For the OpenJDK all patches were executed under:&lt;br /&gt;URL: https://openjdk.dev.java.net/svn/openjdk/jdk/trunk&lt;br /&gt;Repository Root: https://openjdk.dev.java.net/svn/openjdk&lt;br /&gt;Revision: 239&lt;br /&gt;And they can be downloaded &lt;a href="https://www.jfrog.org/svn-jfrog/abstract-enum/openjdk/patch/"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;What's next&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;So, now what's left to do is to remove the "extends Enum" and make the generics declarations "&lt;e&gt;&gt;" generated by synthetic sugar.&lt;br /&gt;&lt;/e&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;I think that during the work on generics I will try to see the difficulty of having generics for Enum also?&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;But before all that I think I will start to apply this internal JDK to the fields-enum and other projects, to really judge the improvements...&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The "reopened" RFE was accepted&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Thank you for taking the time to suggest this enhancement to the Java Standard Edition.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;We have determined that this report is an RFE and has been entered into our internal RFE tracking system under Bug Id: &lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6570766"&gt;6570766&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;1. Voting for the RFE&lt;br /&gt;Click &lt;a href="http://bugs.sun.com/bugdatabase/addVote.do?bug_id=6570766"&gt;http://bugs.sun.com/bugdatabase/addVote.do?bug_id=6570766&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;2. Adding the report to your Bug Watch list.&lt;br /&gt;You will receive an email notification when this RFE is updated. Click &lt;a href="http://bugs.sun.com/bugdatabase/addBugWatch.do?bug_id=6570766"&gt;http://bugs.sun.com/bugdatabase/addBugWatch.do?bug_id=6570766&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-6848082662197672373?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/6848082662197672373/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=6848082662197672373' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/6848082662197672373'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/6848082662197672373'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2007/06/patch-abstract-enum-with-openjdk.html' title='PATCH Abstract Enum with OpenJDK'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-5062053404332551470</id><published>2007-06-18T21:10:00.000+03:00</published><updated>2007-10-17T20:29:32.504+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='abstract enum'/><category scheme='http://www.blogger.com/atom/ns#' term='openjdk'/><title type='text'>Abstract Enum on KSL</title><content type='html'>&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt; The reasons in few lines&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Give the ability to create abstract classes between the final enum declaration containing the static enumerated values, and the abstract superclass for all enum java.lang.Enum.&lt;br /&gt;&lt;/div&gt;So an AbstractColumn.java file can contain:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;public abstract enum AbstractColumn {&lt;br /&gt;  String columnName;&lt;br /&gt;  int precision;&lt;br /&gt;   AbstractColumn() {&lt;br /&gt;      columnName = name();&lt;br /&gt;      precision = 0;&lt;br /&gt;  }&lt;br /&gt; AbstractColumn(String c, int p) {&lt;br /&gt;  ....&lt;br /&gt;  }&lt;br /&gt;  public String getColumnName() {return columnName();}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;And inside an O/R Mapping framework an annotation can be:&lt;br /&gt;&lt;code&gt; public interface @Column {AbstractColumn definition();}&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;And then the application users have the level of indirection they need to provide logic to the framework using the static annotations. For example:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;public enum CustomerColumn extends AbstractColumn {&lt;br /&gt;  firstName, lastName, age;&lt;br /&gt;   public String getColumnName() {&lt;br /&gt;      return StringUtils.capitalizeWithUnderscore(name());&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@Entity&lt;br /&gt;public class Customer {&lt;br /&gt;  @Column(definition = CustomerColumn.firstName)&lt;br /&gt;  private String firstName;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Then all the problems of hardcoded schema names in JPA entities (quite annoying), copy/paste, string based errors (no type safety), and so on disappear.&lt;br /&gt;From my experience, the limitations of Annotations are really pushing developers away, and this feature can unlock the issue.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;The KSL or OpenJDK patch&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Please check &lt;a href="http://freddy33.blogspot.com/2007/06/dive-in-ksl.html"&gt;A dive into the KSL&lt;/a&gt; A big dive (more like drowning) into the Kitchen Sink Language!, for how this patch was made and the references.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;So, I finally manage to write a patch for abstract enum with the following limitations:&lt;br /&gt;&lt;/div&gt;&lt;ol&gt;&lt;li style="text-align: justify;"&gt;Abstract enum cannot extends other abstract enums (the extends close needs to be empty)&lt;/li&gt;&lt;li style="text-align: justify;"&gt;You need to declare the constructors you are using in the final enum extending the abstract enum and use super() calls if needed&lt;/li&gt;&lt;li style="text-align: justify;"&gt;You can declare the generics signature &lt;e&gt;&gt; in the abstract Enum, and use enum MyEnum&lt;myenum&gt; for the final one. It does not mean generics are allowed for enum,&lt;/myenum&gt;&lt;/e&gt;&lt;/li&gt;&lt;li style="text-align: justify;"&gt;&lt;e&gt;&lt;myenum&gt;but for the moment I did not find synthetic sugar for generating generics that I could based my work on?&lt;/myenum&gt;&lt;/e&gt;&lt;/li&gt;&lt;li style="text-align: justify;"&gt;&lt;e&gt;&lt;myenum&gt;I had the following problem: '''The enum containing anonymous classes does not work anymore with this patch'''. The main problem is that after Check an implicit abstract flag is set on the enum and don't find a way to distinguish between the implicit and explicit abstract flag :-( I solved it using tree.mods and check for protected constructors in the second version of the patch.&lt;/myenum&gt;&lt;/e&gt;&lt;/li&gt;&lt;li style="text-align: justify;"&gt;&lt;e&gt;&lt;myenum&gt;So the only problem left is the usage of Abstract Enum in Annotations. It works at compile time but failed at runtime. So I need to work on the OpenJDK now. I'm getting:&lt;/myenum&gt;&lt;/e&gt;&lt;/li&gt;&lt;/ol&gt;&lt;e&gt;&lt;myenum&gt;&lt;code&gt;java.lang.annotation.AnnotationTypeMismatchException: Incorrectly typed data found for annotation element public abstract abstractEnum.annotation.AbstractE2 abstractEnum.annotation.AnnoAETest.ae2() (Found data of type LabstractEnum/annotation/E21;.one)&lt;br /&gt;       at sun.reflect.annotation.AnnotationTypeMismatchExceptionProxy.generateException(AnnotationTypeMismatchExceptionProxy.java:56)&lt;br /&gt;       at sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:74)&lt;br /&gt;       at $Proxy3.ae2(Unknown Source)&lt;br /&gt;       at abstractEnum.annotation.AnnoAEUsage.main(AnnoAEUsage.java:21)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/myenum&gt;&lt;/e&gt;&lt;div style="text-align: justify;"&gt;&lt;e&gt;&lt;myenum&gt;The patch is here &lt;a href="http://www.jfrog.org/sites/fred/Abstract_Enum_in_KSL_second_version.patch"&gt;Abstract_Enum_in_KSL_second_version.patch&lt;/a&gt; which is based on "compiler-1.7.0-ea-b05". I applied the patch to "openjdk/jdk7/b13" in the folder "j2se" and it matches. I did not test the rebuild, yet.&lt;/myenum&gt;&lt;/e&gt;&lt;br /&gt;&lt;e&gt;&lt;myenum&gt;&lt;/myenum&gt;&lt;/e&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;e&gt;&lt;myenum&gt;The test code is based on a closed bug number about abstract enum (Bug ID: 6507006) is here &lt;a href="http://www.jfrog.org/sites/fred/JtregTests.jar"&gt;here JtregTests.jar&lt;/a&gt;, and only the test of abstract enum in annotations fails.&lt;/myenum&gt;&lt;/e&gt;&lt;br /&gt;&lt;e&gt;&lt;myenum&gt;&lt;/myenum&gt;&lt;/e&gt;&lt;/div&gt;&lt;e&gt;&lt;myenum&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The draft for JSL modifications&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;8.1.1.1 abstract Classes&lt;/span&gt;&lt;br /&gt;Enum types (§8.9) can be declared abstract.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;8.1.4 Superclasses and Subclasses&lt;/span&gt;&lt;br /&gt;The optional extends clause in a normal class declaration specifies the direct&lt;br /&gt;superclass of the current class.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;   Super:&lt;br /&gt;       extends ClassType&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;The following is repeated from §4.3 to make the presentation here clearer:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;   ClassType:&lt;br /&gt;       TypeDeclSpecifier TypeArgumentsopt&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;A class is said to be a direct subclass of its direct superclass. The direct super-class is the class from whose implementation the implementation of the current class is derived. The direct superclass of an enum type E is Enum&lt;e&gt;, unless a SuperEnum is declared.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;8.9 Enums&lt;/span&gt;&lt;br /&gt;An enum declaration has the form:&lt;br /&gt;   EnumDeclaration:&lt;br /&gt;       ClassModifiers &lt;small&gt;''opt''&lt;/small&gt; enum Identifier SuperEnum&lt;small&gt;''opt''&lt;/small&gt; Interfaces&lt;small&gt;''opt''&lt;/small&gt; EnumBody&lt;br /&gt;   SuperEnum:&lt;br /&gt;       extends EnumType&lt;br /&gt;   EnumType:&lt;br /&gt;        TypeDeclSpecifier&lt;br /&gt;   EnumBody:&lt;br /&gt;       { EnumConstants&lt;small&gt;''opt''&lt;/small&gt; ,&lt;small&gt;''opt''&lt;/small&gt; EnumBodyDeclarations&lt;small&gt;''opt''&lt;/small&gt; }&lt;br /&gt;&lt;br /&gt;The body of an enum type may contain enum constants, if the enum is not declared abstract. An enum constant defines an instance of the enum type. A non abstract enum type has no instances other than those defined by its enum constants.&lt;br /&gt;The superclass of an enum can only be another enum declared abstract.&lt;br /&gt;Generics declaration enum are not allowed, and will result in a compile-time error.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;14.11 The switch Statement&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The type of the Expression must be char, byte, short, int, Character,&lt;br /&gt;Byte, Short, Integer, or a non abstract enum type (§8.9), or a compile-time error occurs.&lt;br /&gt;&lt;br /&gt;&lt;/e&gt;&lt;/myenum&gt;&lt;/e&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-5062053404332551470?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/5062053404332551470/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=5062053404332551470' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/5062053404332551470'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/5062053404332551470'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2007/06/abstract-enum-on-ksl.html' title='Abstract Enum on KSL'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-1588304533786435658</id><published>2007-06-17T01:48:00.000+03:00</published><updated>2007-10-17T20:29:32.505+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='abstract enum'/><category scheme='http://www.blogger.com/atom/ns#' term='openjdk'/><title type='text'>A Dive in KSL</title><content type='html'>&lt;span style="font-style: italic;font-size:130%;" &gt;&lt;span style="font-weight: bold;"&gt;WOW, what an experience&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;The Dive&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I just finally emerged from the deep ocean of the KSL (Kitchen Sink Language). That was one of my most challenging coding experience, ever.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;The code is very complex (A compiler after all), very clean, using OO completely to the 3rd level, and having this strange results:&lt;br /&gt;&lt;/div&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;"100% code coverage, gives you 10% usage coverage"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;My dive was guided by the &lt;a href="http://openjdk.java.net/groups/compiler/"&gt;Compiler group&lt;/a&gt;:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Joseph D. Darcy's Sun Weblog &lt;a href="http://blogs.sun.com/darcy/entry/so_you_want_to_change"&gt;So You Want To Change&lt;/a&gt;,&lt;/li&gt;&lt;li&gt;Alexander Hristov &lt;a href="http://www.ahristov.com/tutorial/java-compiler.html"&gt;Hacking the OpenJDK compiler&lt;/a&gt;&lt;/li&gt;&lt;li&gt;and Matthias Ernst's Weblog &lt;a href="http://mernst.org/blog/rss.xml#Cascading-First-Patch"&gt;Cascading First Patch&lt;/a&gt; which gave me the energy to try.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;First, I wanted to use the &lt;a href="http://openjdk.java.net/"&gt;OpenJDK project&lt;/a&gt; but the I did not manage to execute the Ant atsk for building and testing just the javac compiler. Furthermore, I'm an IntelliJ user (hard to change my habits) and reconfiguring the source paths to exclude all except the classes needed by javac was not on my agenda ;-)&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Building the KSL javac&lt;/span&gt;&lt;br /&gt;So I went for the &lt;a href="https://ksl.dev.java.net/"&gt;Kitchen Sink Language&lt;/a&gt; project.&lt;br /&gt;The README.html page after subversion checkout is quite helpful, and the build/test environment is good. You need to configure the "build.properties" like:&lt;br /&gt;&lt;div&gt;&lt;code&gt;&lt;/code&gt;&lt;pre&gt;&lt;br /&gt;build.jdk.version = 1.7.0&lt;br /&gt;build.release = ${build.jdk.version}-opensource&lt;br /&gt;build.number = b00&lt;br /&gt;build.user.release.suffix = ${user.name}_${build.fullversion.time}&lt;br /&gt;build.full.version = ${build.release}-${build.user.release.suffix}-${build.number}&lt;br /&gt;&lt;br /&gt;# Set jtreg.home to jtreg installation directory&lt;br /&gt;jtreg.home=/work/java.net/jtreg&lt;br /&gt;&lt;br /&gt;# Set test.jdk.home to baseline JDK used to run the tests&lt;br /&gt;#test.jdk.home=jdk&lt;br /&gt;test.jdk.home=/opt/java/1.7.0&lt;br /&gt;&lt;br /&gt;compiler.source.level = 1.5&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;The /opt/java/1.7.0 is pointing to a previously build OpenJDK trunk (rev 237).&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I did not manage to execute the jtreg test from ant. It seems that the jtreg Ant task lost the basedir?&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;So I modified it to run jtreg directly (for linux), with my personal filter for abstractEnum:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;fail&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;unless=&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;"jtreg.home"&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;message=&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;"Property 'jtreg.home' needs to be set to the jtreg installation directory."&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt;/&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;fail&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;unless=&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;"test.jdk.home"&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;message=&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;"Property 'test.jdk.home' needs to be set to the baseline JDK to be used to run the tests"&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt;/&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;exec&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;command=&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;"${jtreg.home}/linux/bin/jtreg"&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;arg&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;value=&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;"-jdk:${test.jdk.home}"&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt;/&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;arg&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;value=&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;"-Xbootclasspath/p:${dist.javac}/lib/javac.jar"&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt;/&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;arg&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;value=&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;"-verbose"&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt;/&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;arg&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;value=&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;"-dir:test"&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt;/&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;arg&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;value=&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;"-r:${build.jtreg}/work"&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt;/&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;arg&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;value=&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;"-w:${build.jtreg}/report"&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt;/&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;arg&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;value=&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(239, 239, 239); font-weight: bold;"&gt;"tools/javac/abstractEnum"&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt;/&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;  &lt;&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt;/&lt;/span&gt;&lt;span style="background-color: rgb(239, 239, 239);"&gt;exec&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I also configured an IntelliJ project, containing the sources, the test sources and the Ant build.xml file.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Then I found out that I could not debug the compiler because it uses &lt;code&gt;debuglevel="source,lines"&lt;/code&gt; when IntelliJ needs &lt;code&gt;debuglevel="source,lines,vars"&lt;/code&gt;, so I changed the build.xml.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Creating test cases&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;So, like every good Test Driven developer I started the work by writting the java code I wanted the compiler to accept. To integrate into the test suite you need jtreg. It is very easy to understand and use, and I really like the simple tags. I mainly developed by example looking at other tests definitions.&lt;br /&gt;&lt;/div&gt;So my first test was:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;abstract&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;enum&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;AE1 &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;    int&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;i;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    AE1() {&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;i=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(255, 255, 255);"&gt;2&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;}&lt;br /&gt;   AE1(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;pi)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;i=&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;pi;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;    public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; getI() {&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;i;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;To compile it, the parser needed to be changed and the clean code of the Parser class makes it easy. I used to work with javacc, and I really think direct java coding of a grammar is a lot more readable, "easier" to debug and to extend.&lt;br /&gt;&lt;br /&gt;So, after the parser, I created another test:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;enum&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;E1 &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;extends&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; AE1 {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;    one(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(255, 255, 255);"&gt;1&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;),&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;two;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    E1() {&lt;br /&gt;   }&lt;br /&gt;   E1(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;pi)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;        super&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;pi)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;   }&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;Here I got bad class file all the time when the resolving of AE1 took place. Wanting to move forward I created one java file with all the classes inside, to ease the loadClass():&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;AE2 &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;    AbstractE2 &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ae2;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;static&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; main(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String[&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;] &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;args)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;        System.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;out.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;println(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"Before"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;        AE2 &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;t &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;AE2(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;        t.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ae2 &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= E21.one;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;        System.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;out.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;println(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"Youpi "&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;t.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ae2.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;f()+&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"  "&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;t.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ae2.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;full());&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;        t.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ae2 &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= E22.twenty2;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;        System.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;out.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;println(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"Youpi "&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;t.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ae2.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;full());&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;        System.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;out.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;println(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"After"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;        E21 &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;e21 = E21.one;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;        switch&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; (&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;e21)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;   &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;        case&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; one:&lt;br /&gt;               &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;System.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;out.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;println(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"Got 1"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;           &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;break&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;           &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;case&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; two:&lt;br /&gt;       &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;        System.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;out.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;println(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"Got 2"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;       &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;    break&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;abstract&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;enum&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;AbstractE2&lt;span style="font-family: monospace;"&gt;&lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;E&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;    public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; f() {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;        return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; ordinal();&lt;br /&gt;   }&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;    public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;full() {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;        return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; name() + &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;":"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; + ordinal();&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;enum&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;E21 &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;extends&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; AbstractE2&lt;e21&gt; {&lt;br /&gt;   one, two;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;enum&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;E22 &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;extends&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; AbstractE2&lt;e22&gt; {&lt;br /&gt;   twenty2, twenty3;&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;This removed the loadClass issue and gave me all the errors related to actual compiler work. Here it took me some time to understand who is really doing what, and to control a step by step approach.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Customizing the environment&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;First, the compiler needs to be compiled with himself. So, the Ant does it in 2 steps, compile the bootstrap compiler then the javac compiler with the bootstrap. The problem is that if you destroyed the code, there is no way to move. To protect against this problem, you need to make sure you have a good set of if (...) that identify the special case you are working on and not anything else. For the "abstract enum" it took me too much time to identify this good tests (enum like before, enum with abstract declaration).&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Second, There are a lot of steps in the compilation, and to control it found this in RecognizedOptions :&lt;br /&gt;&lt;/div&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255); font-style: italic;"&gt;/* This is a back door to the compiler's option table.&lt;br /&gt;* -XDx=y sets the option x to the value y.&lt;br /&gt;* -XDx sets the option x to the value x.&lt;br /&gt;*/&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; HiddenOption(XD) {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;     String &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;s;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;     &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;boolean&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; matches(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;s)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;         this&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;s &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;s;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;         &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;s.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;startsWith(name.optionName);&lt;br /&gt;    }&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;     public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;boolean&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; process(Options options, &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;option)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;         s &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;s.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;substring(name.optionName.length());&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;         int&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;eq &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;s.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;indexOf(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;'='&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;         String &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;key &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= (&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;eq &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;&amp;lt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(255, 255, 255);"&gt;0&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;) ? &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;s &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;s.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;substring(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(255, 255, 255);"&gt;0&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;eq)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;         String &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;value &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= (&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;eq &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;&amp;lt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(255, 255, 255);"&gt;0&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;) ? &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;s &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;s.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;substring(&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;eq+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(255, 255, 255);"&gt;1&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;         options.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;put(&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;key,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;value)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;         return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;false&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;    }&lt;br /&gt;},&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;And this in the JavaCompiler :&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;compilePolicy = CompilePolicy.decode(options.get(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"compilePolicy"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;));&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;static&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; CompilePolicy decode(String option) {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; (option == &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;)&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; DEFAULT_COMPILE_POLICY;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;else&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; (option.equals(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"attr"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;))&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; ATTR_ONLY;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;else&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; (option.equals(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"check"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;))&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; CHECK_ONLY;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;else&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; (option.equals(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"simple"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;))&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; SIMPLE;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;else&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; (option.equals(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"byfile"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;))&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; BY_FILE;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;else&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; (option.equals(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"bytodo"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;))&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; BY_TODO;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;else&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;     &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; DEFAULT_COMPILE_POLICY;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div style="text-align: justify;"&gt;There is also a lot of good assertions inside the compiler code that better be activated. So, I create a small java class playing with the options and activating Javac main directly.&lt;br /&gt;&lt;/div&gt;And here is list of options I used:&lt;br /&gt;&lt;span style="font-style: italic;"&gt;For the JVM level options:&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;-ea -esa&lt;/span&gt; This one is at the JVM level of the activation of the test code.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;-Xbootclasspath/p:dist/lib/javac.jar&lt;/span&gt; becareful you need jdk 1.7.0 to run it&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-style: italic;"&gt;For the javac options:&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;-XDcompilePolicy=attr&lt;/span&gt; for attribute only pass&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;-XDcompilePolicy=simple&lt;/span&gt; do the job in a very linear way, which makes the visitor on the code happens in a very different order than normal compile. I found it a very important check to verify that the code respect the visitor pattern and code of the compiler.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;-printsource&lt;/span&gt; is generating XXX.java files instead of XXX.class and do also a different visitor activation. Very important step to check the Parser/MemberEnter steps.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;-XDverboseCompilePolicy&lt;/span&gt; for showing what the compiler is doing. Very important.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;-verbose&lt;/span&gt; standard and sometimes annoying (I removed it after a while)&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;-XDdev&lt;/span&gt; activate dev verbose (Don't know exactly what it means)&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;-Xlint:unchecked&lt;/span&gt; verify when you messed up with generics ;-)&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;-XDstdout&lt;/span&gt; very helpful to have compile error in standard out and compiler crashes and exception in error.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;So &lt;a href="https://www.jfrog.org/svn-jfrog/abstract-enum/ksl/test/src/test/com/sun/tools/javac/abstractEnum/TestAbstractEnum.java"&gt;here&lt;/a&gt; is my small test class that helped me a lot (Short cycle compile/test/debug).&lt;br /&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;The going down&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;div style="text-align: justify;"&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;This was really, really tough times for me. The issue is that java.lang.Enum does not have a default constructor but harcoded (String name, int ordinal) params. So Attr, TransTypes and even Lower, keep adding/removing this arguments types from the list of type parameters. The ''enum XXX'' and ''abstract enum YYY'' have the name and ordinal parameter added during the "synthetic sugar" phase of the Lower visitor. So, it does not match. I finally solved the issues the following ways:&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;br /&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/div&gt;&lt;ol&gt;&lt;li&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;Make some nice good test isDeclaredEnum() and isAbstractEnum() on the Symbol class&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/li&gt;&lt;li&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;Allow enum to call super of an abstract enum&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/li&gt;&lt;li&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;Found out that only the erasure_field method type has the 2 extra parameters, allowing a nice test (sugar already done or not)&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/li&gt;&lt;/ol&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;br /&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;div style="text-align: justify;"&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;When I finally manage to compile all the classes in one file "AE2.java", I went on the bad class file issue.&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;br /&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/div&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;The final&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;I found out that a bad compiled class is a bad class. Logical no!&lt;br /&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;div style="text-align: justify;"&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;So, after solving all the issues above, my class was good. The last problem was the signature of abstract enum classes loaded from a XXX.class file. Here again the issue was with the erasure_field is null by default on class load, and in enum he is the only one to contain name and ordinal...&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;br /&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/div&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;&lt;string&gt;So, I just initialized it on ClassReader with the first well defined type.&lt;br /&gt;Perfect, ''abstract enum'' at last...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Links&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;The patch and the tests are available &lt;a href="http://www.jfrog.org/sites/fred/AbstractEnumOnKSL.tgz"&gt;here AbstractEnumOnKSL.tgz&lt;/a&gt;&lt;br /&gt;Starting to work on the annotations now...&lt;br /&gt;&lt;br /&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;/string&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-1588304533786435658?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/1588304533786435658/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=1588304533786435658' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/1588304533786435658'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/1588304533786435658'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2007/06/dive-in-ksl.html' title='A Dive in KSL'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-5041651849318401991</id><published>2007-06-01T01:34:00.000+03:00</published><updated>2007-10-17T20:28:44.323+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='abstract enum'/><title type='text'>State Machine with abstract enum</title><content type='html'>&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Previous blogs&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Writing this blog I found out that the subject of state machine with annotations was already covered in:&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://weblogs.java.net/blog/carcassi/archive/2007/02/finite_state_ma_1.html"&gt;Gabriele Carcassi blog&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://jroller.com/page/eu?entry=coding_workflow_in_java_with%20James"&gt;Strachan's BeanFlow&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;I will talk about my experience and personal design, but mainly add the point on why "abstract enum" will help a lot.&lt;br /&gt;&lt;/div&gt;&lt;span class="down" style="display: block;" id="formatbar_CreateLink" title="Link" onmouseover="ButtonHoverOn(this);" onmouseout="ButtonHoverOff(this);" onmouseup="" onmousedown="CheckFormatting(event);FormatbarButton('richeditorframe', this, 8);ButtonMouseDown(this);"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;state machine and code&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;First of all, since I wrote &lt;a href="http://www.blogger.com/2006/01/mda-is-dead-long-live-aada.html"&gt;AADA&lt;/a&gt; I'm convince that UML helps you visualize and conceptualize your code and that's were it should stop. Trying to extract to annotate the UML meta-model so that some nice Java code will be generated, is a proof that the target language and framework are missing features.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;For all static UML diagrams, it takes less energy to write a Java class in modern IDE than using any UML tool. But for dynamic diagram and especially '''State Diagrams''', UML beats Java (and big time if you use the good GOF pattern).&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;Most modern Java framework are solving this issue with XML files:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;In &lt;a href="http://www.springframework.org/webflow"&gt;Spring Web Flow&lt;/a&gt; the &lt;a href="http://springframework.svn.sourceforge.net/viewvc/springframework/spring-webflow/trunk/spring-webflow-samples/phonebook/src/main/webapp/WEB-INF/flows/search-flow.xml?revision=4341&amp;view=markup"&gt;flow definition file&lt;/a&gt; is an XML that points to fields and methods of your java code (like everything in Spring)&lt;/li&gt;&lt;li&gt;All vendor workflow&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.jboss.com/products/jbpm"&gt;JBoss JBPM&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Struts, JSF, ...&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;So with JDK 5, I tried in 2005 to write an event driven state machine with annotations. In general I really prefer to design by events are they are a lot easier to grasp for everyone (business analysist, designers and developers).&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;So my design is basically based on the fact that each event is typed, and activate a specific object in the model. The '''state machine''' design question was: ''Which method should be activated?''&lt;br /&gt;&lt;/div&gt;It is very similar to the previous blogs on the subject.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;abstract enum will save all&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;One of the comment on Gabriele Carcassi blog was: "Actually, BeanFlow uses strings (due to depending on enum fields rather than interfaces) to declare transitions. That's not refactorable. I like this design better." So, the conflict between generic framework (using string) and clean design (using annotations and enum), appeared immediatly.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;So, I tried to write with my design the &lt;a href="http://www.agilemodeling.com/artifacts/stateMachineDiagram.htm"&gt;Seminar State Diagram&lt;/a&gt; from Agile Modeling, and it looks really good:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Seminar &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;SeminarState &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;state;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;maxStudents &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(255, 255, 255);"&gt;10&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;nbStudents &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(255, 255, 255);"&gt;0&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;nbWaitingStudents &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(255, 255, 255);"&gt;0&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@ActifFromState(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;})&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; create() {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;state &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;SeminarState.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;proposed;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@ActifFromState(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255); font-style: italic;"&gt;/*all states*/&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;})&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; cancel(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;CancelEvent &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;e)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;maxStudents &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(255, 255, 255);"&gt;10&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;nbStudents &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(255, 255, 255);"&gt;0&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;nbWaitingStudents &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(255, 255, 255);"&gt;0&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;state &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@ActifFromState(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;SeminarState.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;proposed}&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; schedule() {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;state &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;SeminarState.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;scheduled;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@ActifFromState(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;SeminarState.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;scheduled}&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; open() {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;state &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;SeminarState.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;openForEnrollement;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@ActifFromState(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;SeminarState.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;openForEnrollement}&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; add(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;NewStudentEvent &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;e)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;nbStudents++&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; (&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;nbStudents &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;&amp;gt;= &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;maxStudents)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;state &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;SeminarState.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;full;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@ActifFromState(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;SeminarState.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;full}&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; addWaiting(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;NewStudentEvent &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;e)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;nbWaitingStudents++&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@ActifFromState(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;SeminarState.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;openForEnrollement}&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; remove(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;DropStudentEvent &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;e)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;nbStudents--&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@ActifFromState(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;SeminarState.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;full}&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; removeWaiting(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;DropStudentEvent &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;e)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;nbWaitingStudents--&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; (&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;nbWaitingStudents &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;== &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255); background-color: rgb(255, 255, 255);"&gt;0&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;) {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;state &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;SeminarState.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;openForEnrollement;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@ActifFromState(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;SeminarState.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;full,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;SeminarState.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;openForEnrollement}&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; close() {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;state &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;SeminarState.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;closedForEnrolement;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;SeminarState &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;getState() {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;state;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;It looks like I can express the state in a more concise way than UML. Of course UML is still graphically more powerful.&lt;br /&gt;&lt;/div&gt;The only issue above is that I need the &lt;span style="font-weight: bold;font-size:85%;" &gt;enum SeminarState&lt;/span&gt; to extends &lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:85%;"&gt;abstract enum StateDefinition&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;abstract&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;enum&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;StateDefinition &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; Class getModelClass() {...};&lt;br /&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;StateDefinition &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;getSuperState() {...};&lt;br /&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255); font-style: italic;"&gt;// And many more needed by the framework&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;enum&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;SeminarState &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;implements&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; StateDefinition {&lt;br /&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;proposed,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;scheduled,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;openForEnrollement,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;full,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;closedForEnrolement;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;and define in the State manager framework an annotation&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@Retention(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;RetentionPolicy.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;RUNTIME)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;@Target(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;ElementType.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;METHOD}&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; @&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;interface&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 0); background-color: rgb(255, 255, 255);"&gt;ActifFromState &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;StateDefinition[&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;] value();&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Conclusion&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;It seems to me like most of the XML coding (writing java code in XML) issues, we are seeing today, can be removed if Annotations can have an &lt;span style="font-weight: bold;"&gt;abstract enum&lt;/span&gt; attribute.&lt;br /&gt;I like it...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1846725363010306463-5041651849318401991?l=freddy33.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freddy33.blogspot.com/feeds/5041651849318401991/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1846725363010306463&amp;postID=5041651849318401991' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/5041651849318401991'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1846725363010306463/posts/default/5041651849318401991'/><link rel='alternate' type='text/html' href='http://freddy33.blogspot.com/2007/05/state-machine-with-abstract-enum.html' title='State Machine with abstract enum'/><author><name>Frederic Simon</name><uri>http://www.blogger.com/profile/01537253748863675494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://www.jfrog.org/sites/fred/FredSimon.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1846725363010306463.post-5541199819845614866</id><published>2007-05-24T00:29:00.000+03:00</published><updated>2007-10-17T20:28:44.324+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='abstract enum'/><title type='text'>Why java enum cannot extends?</title><content type='html'>&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;The original need&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I came around this issue in the end of 2004 when trying to parse Rinex files (GPS satellites data). Using JDK 5 I used enum to defined the file format. It was very clean, readable, and made the reading and writing of the parser quite easy. This system of using enum for static grammar declaration is actually used for the javac parser itself also.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;The issue is that I needed to declared multiple enum for each type of lines and all enum entry contained the exact same data. So I ended up with something like:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;enum&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;HeaderFormat &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;info(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;       &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"RINEX VERSION / TYPE"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"F9.2,11X,A1,19X"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    ,&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;VERSION,TYPE)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;creator(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"PGM / RUN BY / DATE "&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"A20,A20,A20"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        ,&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;PROGRAM,RUN_BY,DATE)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;comment(&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"COMMENT             "&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"A60"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;                ,&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;COMMENT)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;endOfHeader(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"END OF HEADER       "&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"60X"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;                ,&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;""&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;final&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;RinexLineFormat &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;_lineFormat;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    HeaderFormat(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;label,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;format,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String...&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;fields)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;this&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;_lineFormat &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; RinexLineFormatImpl(&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;label,format,fields)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;RinexLineFormat &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;getLineFormat() {&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;_lineFormat;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;I needed to delegate all my enum static data to an external class, an I needed to delegate (copy/paste) this for all my XXXFormat enum.&lt;br /&gt;I had one that look like:&lt;br /&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;enum&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;NavigationBodyFormat &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;info(&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"I2,1X,I2.2,1X,I2,1X,I2,1X,I2,1X,I2,F5.1,3D19.12"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;,&lt;br /&gt;       &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;SATELLITE_NUMBER,YEAR,MONTH,DAY,HOUR,MINUTE,SECOND,SV_CLOCK_BIAS,SV_CLOCK_DRIFT,SV_CLOCK_DRIFT_RATE)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;brodacastOrbit1(&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"3X,4D19.12"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;,&lt;br /&gt;       &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;IODE,CRS,DELTA_N,M0)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;brodacastOrbit2(&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"3X,4D19.12"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;,&lt;br /&gt;       &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;CUC,ECCENTRICITY,CUS,SQRT_A)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;brodacastOrbit3(&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;"3X,4D19.12"&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;,&lt;br /&gt;       &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold; font-style: italic;"&gt;TOE,CIC,OMEGA_BIG,CIS)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;final&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;RinexLineFormat &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;_lineFormat;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    NavigationBodyFormat(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;RinexLineFormat &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;lineFormat)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;   &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;_lineFormat &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;lineFormat;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;br /&gt;NavigationBodyFormat(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;format,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String...&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;fields)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;   &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;this&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;_lineFormat &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; RinexLineFormatImpl(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;format,fields)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;RinexLineFormat &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;getLineFormat() {&lt;br /&gt;   &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;_lineFormat;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;void&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; read(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;line,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Map&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;Object&amp;gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;container)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;   getLineFormat().read(&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;line,container)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;I was not too happy about this but it was OK.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;But, then we started to do a lot of JPA migrations and the need for property declaration and/or Method and Field references, and their usage in annotations was raised again.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;When trying to solve this problem, I wrote &lt;a href="http://www.jfrog.org/sites/jfrog-reflect/1.0/xref/index.html"&gt;jfrog reflect xref&lt;/a&gt; and found out that I needed to extends enum again.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Solution&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I try to read all around this extends limitation &lt;a href="http://blogs.sun.com/ahe/entry/selftypes"&gt;Self types&lt;/a&gt; (aka type of this) from &lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6479372"&gt;Peter Ahe&lt;/a&gt;, and for me it resumes to one point: ''You cannot extends a class that is self-referencing in its generics.'' I may be totally wrong here, but anyway I'll stick to that.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;So, that's why &lt;code&gt;java.lang.Enum&lt;e&gt;&lt;/e&gt;&lt;/code&gt; cannot be extended. But if you allow only one extension that will replace the class Enum, it should be quite easy. So I will really like to see &lt;code&gt;"abstract enum&lt;/code&gt;&lt;code&gt;"&lt;/code&gt; appears in JDK 7. The Rinex parser code will then look like:&lt;br /&gt;&lt;/div&gt;&lt;pre  style="border: 0.01mm solid rgb(0, 0, 0); padding: 4px; line-height: 130%; background-color: rgb(255, 255, 255);font-family:monospace;"&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;abstract&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;enum&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;EnumFormat &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;final&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;_label;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;final&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;_format;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;final&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String[&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;] &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;_fields;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;private&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;final&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;RinexLineReader &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;_lineReader;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;    EnumFormat(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;label,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;format,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;fields)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;this&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;_label &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;label;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;this&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;_format &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;format;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;StringTokenizer &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;fieldsStringTokenizer &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; StringTokenizer(&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;fields,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;","&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;List &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;fieldsList &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; ArrayList();&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;while&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; (&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;fieldsStringTokenizer.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;hasMoreTokens()) {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;fieldsList.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;add(&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;fieldsStringTokenizer.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;nextToken());&lt;br /&gt;    }&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;this&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;_fields &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;fieldsList.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;toArray(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String[&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128); background-color: rgb(255, 255, 255);"&gt;fieldsList.&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;size()]);&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;_lineReader &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;new&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; RinexLineReaderImpl(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;this&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;EnumFormat(&lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;label,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;format,&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 153, 0); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;String...&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;fields)&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt; {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;this&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;_label &lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0); background-color: rgb(255, 255, 255);"&gt;label;&lt;br /&gt;&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 128); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;this&lt;/span&gt;&lt;span style="background-color: rgb(255, 255, 255);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(102, 14, 122); background-color: rgb(255, 255, 255); font-weight: bold;"&gt;_format &lt;/span&gt;&lt;span style="background-color: rgb
