United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4164450 JSR 199: Standard interface for Java compilers
JDK-4164450 : JSR 199: Standard interface for Java compilers

Details
Type:
Enhancement
Submit Date:
1998-08-07
Status:
Closed
Updated Date:
2006-03-15
Project Name:
JDK
Resolved Date:
2005-08-10
Component:
tools
OS:
solaris_8,solaris_2.5.1,generic,windows_98,windows_xp,windows_95,windows_2000
Sub-Component:
javac
CPU:
x86,sparc,generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
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
Fixed Versions:

Related Reports
Duplicate:
Duplicate:
Duplicate:
Duplicate:
Duplicate:
Duplicate:
Duplicate:
Duplicate:
Duplicate:
Relates:
Relates:
Relates:
Relates:
Relates:

Sub Tasks

Description
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

                                    

Comments
PUBLIC COMMENTS

.
                                     
2004-09-26
WORK AROUND



Name: diC59631			Date: 08/07/98


See above
======================================================================
                                     
2004-09-26
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
mustang


                                     
2004-09-26
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
                                     
2005-03-10
SUGGESTED FIX

See http://javac.sfbay/home/pv149515/jsr199/

###@###.### 2005-05-18 02:30:24 GMT
                                     
2005-05-18



Hardware and Software, Engineered to Work Together