Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does this method from the JDK make sense to anyone?

Tags:

java

I came across this method in the JDK

From com.sun.org.apache.xml.internal.serializer.Version;

  public static int getDevelopmentVersionNum()
  { 
    try {   
        if ((new String("")).length() == 0)
          return 0;
        else  
          return Integer.parseInt("");
    } catch (NumberFormatException nfe) {
           return 0;
    }    
  } 

Is this doing anything more than return 0?

I feel like I am missing something. I can only assume this is generated code. ;)

like image 580
Peter Lawrey Avatar asked Jun 15 '11 11:06

Peter Lawrey


3 Answers

It looks like this file is generated from the following Version.src file by textual substitution. So, when @version.DEVELOPER@ variable is empty, the code in question is generated. length() check is needed to return 0 in this case.

like image 193
axtavt Avatar answered Sep 29 '22 09:09

axtavt


I think "" is replaced with some string from a configuration file before release. In this case it is empty, but it may also contain a number. If you consider "" to be a variable, this code makes some sense.

like image 42
Sjoerd Avatar answered Sep 29 '22 09:09

Sjoerd


The javadoc on the method indicates that it's meant to designate a development drop that is work in progress. So I would say it makes as much sense as anything else that's meant for internal development use only. It could be that they "wash away" any actual version information from this method once they do a release. Either way, I would not place any significance on it. Unless you are a developer at oracle, working on this particular package.

like image 23
pap Avatar answered Sep 29 '22 09:09

pap