JDK-4164450 : JSR 199: Standard interface for Java compilers
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version:
    1.0,1.1,1.1.3,1.2.0,1.2.1,1.3.1,1.4.0,1.4.2,5.0,6 1.0,1.1,1.1.3,1.2.0,1.2.1,1.3.1,1.4.0,1.4.2,5.0,6
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS:
    generic,solaris_2.5.1,solaris_8,windows_95,windows_98,windows_2000,windows_xp generic,solaris_2.5.1,solaris_8,windows_95,windows_98,windows_2000,windows_xp
  • CPU: generic,x86,sparc
  • Submitted: 1998-08-07
  • Updated: 2017-05-16
  • Resolved: 2005-08-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
6 b47Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Name: diC59631			Date: 08/07/98

Several types of Java applications use dynamically
generated and compiled code. The most obvious example
is a JSP web server.

Currently, the only way to compile dynamically 
generated code is to:

1 - Make a temporary .java file and invoke javac
using Runtime.exec. This is rather inelegant and
prone to problems related to platform dependent
behavior for processes. Its also subject to 
applet security restrictions.

2 - Hack the internals of javac and use the Java
interfaces. It works but its totally undocumented
and unsupported. It also doesn't allow you to use
a different vendor's compiler.

This feature is for a standard interface that
is available as a standard extension to Java.
That way you have a richer way to access the 
compiler (if one is available) without forking a
new process or relying on undocumented features.
You also make it easy for the user to install a
different compiler without breaking the tools
that rely on it.

There are some requirements that the interface
should meet:

1 - Be simple to use.
2 - Be stream-based (not file-based). It should
accept an InputStream (or Reader) for the source
code and generate the class file on an OutputStream.

(Review ID: 36593)
###@###.### 10/26/04 21:05 GMT

SUGGESTED FIX See http://javac.sfbay/home/pv149515/jsr199/ ###@###.### 2005-05-18 02:30:24 GMT

EVALUATION It has occasionally been suggested that a programatic interface to javac and the other tools would be useful to those wishing to embed tool functionality into java programs without relying on local shell or file system behavior. This would make sense, but is not presently a high priority. Note that it is possible to call sun.tools.javac.Main directly now, and invoking javac that way is quite likely to continue to work, although it is formally unsupported. david.stoutamire@Eng 1998-08-24 A similar request has been made via webbug 52641: I wish the compiler were placed in the core java.* tree rather than hidden inside com.sun.tools. But even that wouldn't help much unless its main method were modified so as to accept the source in the form of a String[] rather than reading it from file. This would allow runtime compilation of code snippets entirely within code, which would be a _very_ useful feature. iris.garcia@eng 1999-02-18 **************************************************************** NOTE: if you are interested in participating in the definition of this API, please visit http://groups.yahoo.com/group/javax_compiler **************************************************************** neal.gafter@Eng 2001-07-13 Note that javac would have to be made reentrant to implement this. ###@###.### 2001-11-07 Our plans for Tiger are a scaled-back version of what JSR199 is working on. We are aiming to have this in Tiger in early October. ###@###.### 2003-07-30 Our plans have been scaled back yet further. At this time we expect to do no more than document the entry point to Sun's javac for use within a program. ###@###.### 2003-10-27 This JSR is a priority for Mustang (JDK 6). The following issues will be addressed: * Programmatic API to invoke the compiler * API to access structured diagnostic information * API to override how the compiler reads and writes source and class files. NOTE: the yahoo group is no longer in use. ###@###.### 2005-03-10 18:45:52 GMT

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang

WORK AROUND Name: diC59631 Date: 08/07/98 See above ======================================================================