thanhlong203 / closure-library

Automatically exported from code.google.com/p/closure-library
0 stars 0 forks source link

jscompiler.py Fails to Parse Java Version Without Explanation #287

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run jscompiler.py with a Java 1.6 install that places the version number in 
a line other than the first for any reason.

What is the expected output? What do you see instead?
The script should run successfully. Instead, it complains that Java 1.6 is not 
installed.

What version of the product are you using? On what operating system?
Mac OSX 10.6

Please provide any additional information below.
The _GetJavaVersion() method in jscompiler.py is very fragile. Specifically, 
the line number of the version information is hardcoded.  However, the version 
may not be in that line.  Here's one example:

    Unable to find a $JAVA_HOME at "/usr", continuing with system-provided Java...
    java version "1.6.0_22"
    Java(TM) SE Runtime Environment (build 1.6.0_22-b04-307-10M3261)
    Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03-307, mixed mode)

In this case, the regex will match "..." in the first line (despite the fact 
that 1.6 is installed).

I think that either the regex should be made less fragile or (at the very 
least) the error message should give some hint that it wasn't able to parse the 
version correctly.

Original issue reported on code.google.com by matthewt...@gmail.com on 7 Mar 2011 at 3:23

GoogleCodeExporter commented 8 years ago

Original comment by pall...@google.com on 29 Mar 2011 at 10:23

GoogleCodeExporter commented 8 years ago
Although I have no idea how the string returned by _GetJavaVersion() can look 
like in the general case, I can change the regexp to '[0-9][.0-9]*' so that it 
doesn't match '...'.

Original comment by pall...@google.com on 16 Nov 2011 at 4:26

GoogleCodeExporter commented 8 years ago
please look at http://code.google.com/p/script-cover/issues/detail?id=5

no. You should look for the string "version" in one line.

I am using the shell variable _JAVA_OPTIONS to pass option to java jvm 
(specifially  to use anti-aliasing font), but it prints a first line like 
"Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on" on every call to 
java and to "java -version"

a fix to your GetJavaVersion would be to use something like

version_line = [line for line in proc.stderr.read().splitlines() if 'java 
version' in line][0]

Original comment by solstice.dhiver@gmail.com on 17 Nov 2011 at 4:28

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r1445.

Original comment by Nicholas.J.Santos on 5 Dec 2011 at 6:28

GoogleCodeExporter commented 8 years ago
wtf! I wasn't clear enough? this will not fix the bug

Original comment by solstice.dhiver@gmail.com on 5 Dec 2011 at 9:07

GoogleCodeExporter commented 8 years ago
@solstice.dhiver

Comment on Nov 17 acknowledged. Writing patch.  Please watch tone, it was an 
honest oversight.

Original comment by nn...@google.com on 5 Dec 2011 at 9:16

GoogleCodeExporter commented 8 years ago

Original comment by nn...@google.com on 5 Dec 2011 at 9:40

GoogleCodeExporter commented 8 years ago
Patch sent internally for review -- will hopefully be pushed within a week or 
two.

Thanks,

Nathan

Original comment by nn...@google.com on 6 Dec 2011 at 2:13

GoogleCodeExporter commented 8 years ago
Fixed in r1445

Original comment by nn...@google.com on 24 Apr 2012 at 1:36

GoogleCodeExporter commented 8 years ago
ok. I give up

Original comment by solstice.dhiver@gmail.com on 24 Apr 2012 at 8:31