You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Simon Kitching <si...@chello.at> on 2007/12/20 16:11:20 UTC

Java version compatibility (was Re: svn commit: r605927 - /myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/SimpleDateFormatter.java)

This problem happens no matter what java versions are being talked about. When the aim is to support java N, but the latest is java X then it is difficult to prevent accidents.

Compiler property "source" prevents the use of *language features* that are not supported in the specified version

Compiler property "target" ensures that the generated bytecode is readable by the specified version.

But nothing checks that you are using only APIs provided by the runtime library distributed by that version. Currently the only way to do that is to compile against the runtime lib distributed with that version (which basically means *using* that version to compile).

The CLIRR project does binary-compatibility testing on jars. I have always suspected that it would only need a minor enhancement to generate an "API summary" for the rt.jar of version N of java, and then to be able to automatically check that an app only makes calls to the APIs defined by that summary file. Just need that old 40 hour day in order to get time to do it :-)

Cheers,  Simon

---- Matthias Wessendorf <ma...@apache.org> schrieb:
> I'd be fine with Java5 instead of 1.4
> 
> -M
> 
> On Dec 20, 2007 3:37 PM, Martin Marinschek <ma...@gmail.com> wrote:
> > yes, that is what I'm saying.
> >
> > Saying that this is a bug is maybe pushing it too hard... the
> > attributes just translate into a compiler language level - that does
> > not mean that someone automagically knows all API changes from 1.4 to
> > 1.6 and automatically applies them. The only chance for you to catch
> > all these problems is to actually compile with 1.4.
> >
> >
> > regards,
> >
> > Martin
> >
> > On 12/20/07, Matthias Wessendorf <ma...@apache.org> wrote:
> > > So,
> > >
> > > you say that a configuration like:
> > >
> > > <plugin>
> > >   <groupId>org.apache.maven.plugins</groupId>
> > >   <artifactId>maven-compiler-plugin</artifactId>
> > >   <inherited>true</inherited>
> > >   <configuration>
> > >     <source>1.5</source>
> > >     <target>1.5</target>
> > >   </configuration>
> > > </plugin>
> > >
> > >
> > > does allow you to use JDK6 methods?
> > > That would be a bad bug, IMO.
> > >
> > > -M
> > >
> > > On Dec 20, 2007 3:22 PM, Martin Marinschek <ma...@gmail.com>
> > > wrote:
> > > > Yes, so 1.5/1.6 syntax will correctly be found and disallowed. But API
> > > > changes are not checked for, so a newly added method will not be
> > > > found.
> > > >
> > > >
> > > > regards,
> > > >
> > > > Martin
> > > >
> > > > On 12/20/07, Matthias Wessendorf <ma...@apache.org> wrote:
> > > > > On Dec 20, 2007 3:19 PM, Matthias Wessendorf <ma...@apache.org> wrote:
> > > > > > I thought the compile was configured for source/target not 1.5 || 1.6
> > > > >
> > > > > (the compiler plugin)
> > > > >
> > > > > >
> > > > > > -M
> > > > > >
> > > > > >
> > > > > > On Dec 20, 2007 3:18 PM, Martin Marinschek
> > > <ma...@gmail.com>
> > > > > wrote:
> > > > > > > No - if you are building with 1.6, it won't. Only the language level
> > > is
> > > > > checked.
> > > > > > >
> > > > > > > regards,
> > > > > > >
> > > > > > > Martin
> > > > > > >
> > > > > > >
> > > > > > > On 12/20/07, Matthias Wessendorf <ma...@apache.org> wrote:
> > > > > > > > On Dec 20, 2007 2:45 PM,  <sk...@apache.org> wrote:
> > > > > > > > > Author: skitching
> > > > > > > > > Date: Thu Dec 20 05:45:06 2007
> > > > > > > > > New Revision: 605927
> > > > > > > > >
> > > > > > > > > URL: http://svn.apache.org/viewvc?rev=605927&view=rev
> > > > > > > > > Log:
> > > > > > > > > Remove accidental use of java 1.6 method String.isEmpty
> > > > > > > >
> > > > > > > > isn't the build catching this ?
> > > > > > > >
> > > > > > > > -M
> > > > > > > >
> > > > > > > > >
> > > > > > > > > Modified:
> > > > > > > > >
> > > > > > > >
> > > > >
> > > myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/SimpleDateFormatter.java
> > > > > > > > >
> > > > > > > > > Modified:
> > > > > > > >
> > > > >
> > > myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/SimpleDateFormatter.java
> > > > > > > > > URL:
> > > > > > > >
> > > > >
> > > http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/SimpleDateFormatter.java?rev=605927&r1=605926&r2=605927&view=diff
> > > > > > > > >
> > > > > > > >
> > > > >
> > > ==============================================================================
> > > > > > > > > ---
> > > > > > > >
> > > > >
> > > myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/SimpleDateFormatter.java
> > > > > > > > (original)
> > > > > > > > > +++
> > > > > > > >
> > > > >
> > > myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/SimpleDateFormatter.java
> > > > > > > > Thu Dec 20 05:45:06 2007
> > > > > > > > > @@ -838,7 +838,7 @@
> > > > > > > > >
> > > > > > > > >      private static void formatPattern(DateFormatSymbols
> > > symbols,
> > > > > > > > ParserContext context, String patternSub, boolean yearIsWeekYear,
> > > > > > > > StringBuffer out)
> > > > > > > > >      {
> > > > > > > > > -        if ((patternSub == null) || (patternSub.isEmpty()))
> > > > > > > > > +        if ((patternSub == null) || (patternSub.length() == 0))
> > > > > > > > >          {
> > > > > > > > >              return;
> > > > > > > > >          }
> > > > > > > > > @@ -1137,7 +1137,7 @@
> > > > > > > > >
> > > > > > > > >      public Date parse(String dateStr)
> > > > > > > > >      {
> > > > > > > > > -        if ((dateStr==null) || dateStr.isEmpty())
> > > > > > > > > +        if ((dateStr==null) || (dateStr.length() == 0))
> > > > > > > > >              return null;
> > > > > > > > >
> > > > > > > > >          ParserContext context = parseOps(symbols,
> > > yearIsWeekYear,
> > > > > > > > firstDayOfWeek, ops, dateStr);
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Matthias Wessendorf
> > > > > > > >
> > > > > > > > further stuff:
> > > > > > > > blog: http://matthiaswessendorf.wordpress.com/
> > > > > > > > sessions: http://www.slideshare.net/mwessendorf
> > > > > > > > mail: matzew-at-apache-dot-org
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > >
> > > > > > > http://www.irian.at
> > > > > > >
> > > > > > > Your JSF powerhouse -
> > > > > > > JSF Consulting, Development and
> > > > > > > Courses in English and German
> > > > > > >
> > > > > > > Professional Support for Apache MyFaces
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > >
> > > > > > Matthias Wessendorf
> > > > > >
> > > > > > further stuff:
> > > > > > blog: http://matthiaswessendorf.wordpress.com/
> > > > > > sessions: http://www.slideshare.net/mwessendorf
> > > > > > mail: matzew-at-apache-dot-org
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Matthias Wessendorf
> > > > >
> > > > > further stuff:
> > > > > blog: http://matthiaswessendorf.wordpress.com/
> > > > > sessions: http://www.slideshare.net/mwessendorf
> > > > > mail: matzew-at-apache-dot-org
> > > > >
> > > >
> > > >
> > > > --
> > > >
> > > >
> > > > http://www.irian.at
> > > >
> > > > Your JSF powerhouse -
> > > > JSF Consulting, Development and
> > > > Courses in English and German
> > > >
> > > > Professional Support for Apache MyFaces
> > > >
> > >
> > >
> > >
> > > --
> > > Matthias Wessendorf
> > >
> > > further stuff:
> > > blog: http://matthiaswessendorf.wordpress.com/
> > > sessions: http://www.slideshare.net/mwessendorf
> > > mail: matzew-at-apache-dot-org
> > >
> >
> >
> > --
> >
> >
> > http://www.irian.at
> >
> > Your JSF powerhouse -
> > JSF Consulting, Development and
> > Courses in English and German
> >
> > Professional Support for Apache MyFaces
> >
> 
> 
> 
> -- 
> Matthias Wessendorf
> 
> further stuff:
> blog: http://matthiaswessendorf.wordpress.com/
> sessions: http://www.slideshare.net/mwessendorf
> mail: matzew-at-apache-dot-org


Re: Java version compatibility (was Re: svn commit: r605927 - /myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/SimpleDateFormatter.java)

Posted by Mike Kienenberger <mk...@gmail.com>.
Can't you do something like this to force the rt.jar to be 1.4?

http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javac.html

% javac -target 1.4 -bootclasspath jdk1.4.2/lib/classes.zip -extdirs
"" OldCode.java


On Dec 20, 2007 10:11 AM, Simon Kitching <si...@chello.at> wrote:
> This problem happens no matter what java versions are being talked about. When the aim is to support java N, but the latest is java X then it is difficult to prevent accidents.
>
> Compiler property "source" prevents the use of *language features* that are not supported in the specified version
>
> Compiler property "target" ensures that the generated bytecode is readable by the specified version.
>
> But nothing checks that you are using only APIs provided by the runtime library distributed by that version. Currently the only way to do that is to compile against the runtime lib distributed with that version (which basically means *using* that version to compile).
>
> The CLIRR project does binary-compatibility testing on jars. I have always suspected that it would only need a minor enhancement to generate an "API summary" for the rt.jar of version N of java, and then to be able to automatically check that an app only makes calls to the APIs defined by that summary file. Just need that old 40 hour day in order to get time to do it :-)
>
> Cheers,  Simon
>
> ---- Matthias Wessendorf <ma...@apache.org> schrieb:
> > I'd be fine with Java5 instead of 1.4
> >
> > -M
> >
> > On Dec 20, 2007 3:37 PM, Martin Marinschek <ma...@gmail.com> wrote:
> > > yes, that is what I'm saying.
> > >
> > > Saying that this is a bug is maybe pushing it too hard... the
> > > attributes just translate into a compiler language level - that does
> > > not mean that someone automagically knows all API changes from 1.4 to
> > > 1.6 and automatically applies them. The only chance for you to catch
> > > all these problems is to actually compile with 1.4.
> > >
> > >
> > > regards,
> > >
> > > Martin
> > >
> > > On 12/20/07, Matthias Wessendorf <ma...@apache.org> wrote:
> > > > So,
> > > >
> > > > you say that a configuration like:
> > > >
> > > > <plugin>
> > > >   <groupId>org.apache.maven.plugins</groupId>
> > > >   <artifactId>maven-compiler-plugin</artifactId>
> > > >   <inherited>true</inherited>
> > > >   <configuration>
> > > >     <source>1.5</source>
> > > >     <target>1.5</target>
> > > >   </configuration>
> > > > </plugin>
> > > >
> > > >
> > > > does allow you to use JDK6 methods?
> > > > That would be a bad bug, IMO.
> > > >
> > > > -M
> > > >
> > > > On Dec 20, 2007 3:22 PM, Martin Marinschek <ma...@gmail.com>
> > > > wrote:
> > > > > Yes, so 1.5/1.6 syntax will correctly be found and disallowed. But API
> > > > > changes are not checked for, so a newly added method will not be
> > > > > found.
> > > > >
> > > > >
> > > > > regards,
> > > > >
> > > > > Martin
> > > > >
> > > > > On 12/20/07, Matthias Wessendorf <ma...@apache.org> wrote:
> > > > > > On Dec 20, 2007 3:19 PM, Matthias Wessendorf <ma...@apache.org> wrote:
> > > > > > > I thought the compile was configured for source/target not 1.5 || 1.6
> > > > > >
> > > > > > (the compiler plugin)
> > > > > >
> > > > > > >
> > > > > > > -M
> > > > > > >
> > > > > > >
> > > > > > > On Dec 20, 2007 3:18 PM, Martin Marinschek
> > > > <ma...@gmail.com>
> > > > > > wrote:
> > > > > > > > No - if you are building with 1.6, it won't. Only the language level
> > > > is
> > > > > > checked.
> > > > > > > >
> > > > > > > > regards,
> > > > > > > >
> > > > > > > > Martin
> > > > > > > >
> > > > > > > >
> > > > > > > > On 12/20/07, Matthias Wessendorf <ma...@apache.org> wrote:
> > > > > > > > > On Dec 20, 2007 2:45 PM,  <sk...@apache.org> wrote:
> > > > > > > > > > Author: skitching
> > > > > > > > > > Date: Thu Dec 20 05:45:06 2007
> > > > > > > > > > New Revision: 605927
> > > > > > > > > >
> > > > > > > > > > URL: http://svn.apache.org/viewvc?rev=605927&view=rev
> > > > > > > > > > Log:
> > > > > > > > > > Remove accidental use of java 1.6 method String.isEmpty
> > > > > > > > >
> > > > > > > > > isn't the build catching this ?
> > > > > > > > >
> > > > > > > > > -M
> > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Modified:
> > > > > > > > > >
> > > > > > > > >
> > > > > >
> > > > myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/SimpleDateFormatter.java
> > > > > > > > > >
> > > > > > > > > > Modified:
> > > > > > > > >
> > > > > >
> > > > myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/SimpleDateFormatter.java
> > > > > > > > > > URL:
> > > > > > > > >
> > > > > >
> > > > http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/SimpleDateFormatter.java?rev=605927&r1=605926&r2=605927&view=diff
> > > > > > > > > >
> > > > > > > > >
> > > > > >
> > > > ==============================================================================
> > > > > > > > > > ---
> > > > > > > > >
> > > > > >
> > > > myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/SimpleDateFormatter.java
> > > > > > > > > (original)
> > > > > > > > > > +++
> > > > > > > > >
> > > > > >
> > > > myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/SimpleDateFormatter.java
> > > > > > > > > Thu Dec 20 05:45:06 2007
> > > > > > > > > > @@ -838,7 +838,7 @@
> > > > > > > > > >
> > > > > > > > > >      private static void formatPattern(DateFormatSymbols
> > > > symbols,
> > > > > > > > > ParserContext context, String patternSub, boolean yearIsWeekYear,
> > > > > > > > > StringBuffer out)
> > > > > > > > > >      {
> > > > > > > > > > -        if ((patternSub == null) || (patternSub.isEmpty()))
> > > > > > > > > > +        if ((patternSub == null) || (patternSub.length() == 0))
> > > > > > > > > >          {
> > > > > > > > > >              return;
> > > > > > > > > >          }
> > > > > > > > > > @@ -1137,7 +1137,7 @@
> > > > > > > > > >
> > > > > > > > > >      public Date parse(String dateStr)
> > > > > > > > > >      {
> > > > > > > > > > -        if ((dateStr==null) || dateStr.isEmpty())
> > > > > > > > > > +        if ((dateStr==null) || (dateStr.length() == 0))
> > > > > > > > > >              return null;
> > > > > > > > > >
> > > > > > > > > >          ParserContext context = parseOps(symbols,
> > > > yearIsWeekYear,
> > > > > > > > > firstDayOfWeek, ops, dateStr);
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > Matthias Wessendorf
> > > > > > > > >
> > > > > > > > > further stuff:
> > > > > > > > > blog: http://matthiaswessendorf.wordpress.com/
> > > > > > > > > sessions: http://www.slideshare.net/mwessendorf
> > > > > > > > > mail: matzew-at-apache-dot-org
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > >
> > > > > > > > http://www.irian.at
> > > > > > > >
> > > > > > > > Your JSF powerhouse -
> > > > > > > > JSF Consulting, Development and
> > > > > > > > Courses in English and German
> > > > > > > >
> > > > > > > > Professional Support for Apache MyFaces
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > >
> > > > > > > Matthias Wessendorf
> > > > > > >
> > > > > > > further stuff:
> > > > > > > blog: http://matthiaswessendorf.wordpress.com/
> > > > > > > sessions: http://www.slideshare.net/mwessendorf
> > > > > > > mail: matzew-at-apache-dot-org
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Matthias Wessendorf
> > > > > >
> > > > > > further stuff:
> > > > > > blog: http://matthiaswessendorf.wordpress.com/
> > > > > > sessions: http://www.slideshare.net/mwessendorf
> > > > > > mail: matzew-at-apache-dot-org
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > >
> > > > >
> > > > > http://www.irian.at
> > > > >
> > > > > Your JSF powerhouse -
> > > > > JSF Consulting, Development and
> > > > > Courses in English and German
> > > > >
> > > > > Professional Support for Apache MyFaces
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Matthias Wessendorf
> > > >
> > > > further stuff:
> > > > blog: http://matthiaswessendorf.wordpress.com/
> > > > sessions: http://www.slideshare.net/mwessendorf
> > > > mail: matzew-at-apache-dot-org
> > > >
> > >
> > >
> > > --
> > >
> > >
> > > http://www.irian.at
> > >
> > > Your JSF powerhouse -
> > > JSF Consulting, Development and
> > > Courses in English and German
> > >
> > > Professional Support for Apache MyFaces
> > >
> >
> >
> >
> > --
> > Matthias Wessendorf
> >
> > further stuff:
> > blog: http://matthiaswessendorf.wordpress.com/
> > sessions: http://www.slideshare.net/mwessendorf
> > mail: matzew-at-apache-dot-org
>
>