JDK-7187144 : JavaDoc for ScriptEngineFactory.getProgram() contains an error
  • Type: Bug
  • Component: core-libs
  • Sub-Component: javax.script
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2012-07-26
  • Updated: 2017-02-22
  • Resolved: 2013-07-11
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.
JDK 8 Other
8 b100Fixed openjdk7uFixed
Description
A DESCRIPTION OF THE PROBLEM :
The provided sample implementation of the method getProgram is simply contains syntax error. It is a mix of PHP and Java.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
    public String getProgram(String... statements) {
        int len = 0;
        for (String line : statements) {
            len += 1 + line.length();
        }
        StringBuilder sb = new StringBuilder(len);
        for( String line : statements){
            sb.append(line).append("\n");
        }
        return sb.toString();
    }
ACTUAL -
public String getProgram(String... statements) {
      $retval = "<?\n";
      int len = statements.length;
      for (int i = 0; i < len; i++) {
          $retval += statements[i] + ";\n";
      }
      $retval += "?>";

 }

URL OF FAULTY DOCUMENTATION :
http://docs.oracle.com/javase/6/docs/api/javax/script/ScriptEngineFactory.html#getProgram%28java.lang.String...%29

Comments
EVALUATION See Description.
03-08-2012