[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3978) Expose Hibernate version via non-compile-time constant expression
Steve Ebersole (JIRA)
noreply at atlassian.com
Mon Jun 22 15:20:33 EDT 2009
Expose Hibernate version via non-compile-time constant expression
-----------------------------------------------------------------
Key: HHH-3978
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3978
Project: Hibernate Core
Issue Type: Improvement
Components: core
Reporter: Steve Ebersole
Assignee: Steve Ebersole
Fix For: 3.2.x, 3.3.x, 3.5
Currently we expose the Hibernate version via a public static final field (org.hibernate.cfg.Envrionment#VERSION). It is defined using what JLS terms a compile-time constant expression. The issue with this approach is that compilers are free to inline the value of this field when it is encountered. For example, say a Hibernate user is attempting to do something like:
if ( Environment.VERSION.equals( "3.3.0.ga" ) {
// do something 3.3.0-specific...
}
The issue is that the compiler is free to inline the "Environment.VERSION" reference with its compile-time constant expression value. So if the user compiles this code against Hibernate 3.3.0.ga initially, it does not matter at all what version is present at runtime. The compiler will inline (re: replace) Environment.VERSION with "3.3.0.ga" and that if check will always resolve to true!
http://java.sun.com/docs/books/jls/third_edition/html/binaryComp.html#13.4.9
The same "feature" is not extended to methods. We should make the version accessible only from static method (and we should avoid making it final as it appears some compiler may even inline static final method calls).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list