United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 7181951 ToolProvider.getSystemJavaCompiler() is null if tools.jar put to jre/lib/ext dir
7181951 : ToolProvider.getSystemJavaCompiler() is null if tools.jar put to jre/lib/ext dir

Details
Type:
Bug
Submit Date:
2012-07-05
Status:
Closed
Updated Date:
2012-07-13
Project Name:
JDK
Resolved Date:
2012-07-13
Component:
tools
OS:
windows_7
Sub-Component:
javac
CPU:
x86
Priority:
P3
Resolution:
Not an Issue
Affected Versions:
7
Fixed Versions:

Related Reports

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.7.0_05"
Java(TM) SE Runtime Environment (build 1.7.0_05-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Windows 7x64 SP1
Windows XP SP3

A DESCRIPTION OF THE PROBLEM :
Adding tools.jar to "jre/lib/ext" folder does not work anymore. In JDK 6 it was possible to add tools.jar to "jre/lib/ext" folder and have system java compiler be returned by javax.tools.ToolProvider.getSystemJavaCompiler().
Now with JDK 7 it is no longer working. If I add jar to "jre/lib/ext" folder then ToolProvider.getSystemJavaCompiler() returns null. But if add tools.jar to the "jre/lib" folder then it works.

REGRESSION.  Last worked in version 6u31

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Install JRE 1.7.0_05
2. Compile test code provided.
3. Copy tools.jar to jre/lib/ext folder
4. Run code => and error will be thrown
5. Now move tools.jar from jre/lib/ext to jre/lib folder and re-run => it will work

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
javax.tools.ToolProvider.getSystemJavaCompiler() should return an instance of JavaCompiler class
ACTUAL -
javax.tools.ToolProvider.getSystemJavaCompiler() returns null

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.tools.JavaCompiler;

public class CompilerTest {
  public static void main(String[] args) {
    JavaCompiler systemCompiler =
        javax.tools.ToolProvider.getSystemJavaCompiler();
    if (systemCompiler == null) {
      throw new Error("systemCompiler == null!");
    }
  }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Copy tools.jar to "jre/lib" folder instead of "jre/lib/ext" folder

                                    

Comments
EVALUATION

Closing as not a bug.   That behavior was neither specified nor intended.
                                     
2012-07-13
EVALUATION

I am able to reproduce this as described since JDK7 FCS and in JDK8, if tools.jar is placed in jre/lib/ext then the test case fails, javax.tools.ToolProvider.getSystemJavaCompiler() returns null. The same test using 6u33 does not fail.
                                     
2012-07-12



Hardware and Software, Engineered to Work Together