SeaUrchinBot / closure-library

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

_GetJavaVersion fails if JAVA_TOOL_OPTIONS was defined #501

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Set a variable: export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8
2. Then run closurebuilder.py

What is the expected output? What do you see instead?

It should success however it fails:

Traceback (most recent call last):
  File "../common/closure-library/closure/bin/build/closurebuilder.py", line 256, in <module>
    main()
  File "../common/closure-library/closure/bin/build/closurebuilder.py", line 241, in main
    options.compiler_flags)
  File "/Users/nishio/cur/webui/common/closure-library/closure/bin/build/jscompiler.py", line 50, in Compile
    if not (distutils.version.LooseVersion(_GetJavaVersion()) >=
  File "/Users/nishio/cur/webui/common/closure-library/closure/bin/build/jscompiler.py", line 34, in _GetJavaVersion
    return _VERSION_REGEX.search(version_line).group(1)

The reason is _GetJavaVersion make an incorrect assumption that version number 
appears on the first line. In this case it is not truth:

$ java -version
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
java version "1.6.0_35"
Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
Java HotSpot(TM) Client VM (build 20.10-b01-428, mixed mode)

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

Trunk, Max OS X 10.7.5 and Python 2.7.3

Original issue reported on code.google.com by nishio.hirokazu@gmail.com on 1 Oct 2012 at 7:20

GoogleCodeExporter commented 9 years ago
I can confirm that this issue is affecting me.

Here's the my output of `java -version`:

Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on
java version "1.7.0_17"
OpenJDK Runtime Environment (IcedTea7 2.3.8) (ArchLinux build 
7.u17_2.3.8-1-x86_64)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

Note that the java version is on the second line.

Original comment by gugubro1 on 29 Mar 2013 at 11:23

GoogleCodeExporter commented 9 years ago
I can also confirm that this issue is affecting me.

java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)

Original comment by sezgisen...@gmail.com on 31 Mar 2013 at 7:55

GoogleCodeExporter commented 9 years ago
Here is my patch. It works well.

Index: closure/bin/build/jscompiler.py
===================================================================
--- closure/bin/build/jscompiler.py
+++ closure/bin/build/jscompiler.py
@@ -30,8 +30,9 @@
   """Returns the string for the current version of Java installed."""
   proc = subprocess.Popen(['java', '-version'], stderr=subprocess.PIPE)
   unused_stdoutdata, stderrdata = proc.communicate()
-  version_line = stderrdata.splitlines()[0]
-  return _VERSION_REGEX.search(version_line).group(1)
+  for line in stderrdata.splitlines():
+    m = _VERSION_REGEX.search(line)
+    if m: return m.group(1)

 def Compile(compiler_jar_path, source_paths, flags=None):

Original comment by nishio.hirokazu@gmail.com on 23 Oct 2013 at 4:38

Attachments: