/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8002091
* @summary Test options patterns for javac,javah,javap and javadoc using
* javac as a test launcher. Create a dummy javac and intercept options to check
* reception of options as passed through the launcher without having to launch
* javac. Only -J and -cp ./* options should be consumed by the launcher.
* @run main ToolsOpts
* @author ssides
*/
{"-J-Xmx128m"},
{"-J-version"},
{"-J-XshowSettings:vm"},
{"-J-Xdiag"},
{"-J-showversion"},
{"-J-version", "-option"},
{"-option"},
{"-option:sub"},
{"-option:sub-"},
{"-option:sub1,sub2"}, // -option:list
{"-option:{sub1,sub2,sub3}"}, // -option:{list}
{"-option:{{sub1,sub2,sub3}}"},// -option:{{list}}
{"-option=value"},
{"-Dpk1.pk2.pk3"}, // dot in option
{"-Dpk1.pk2=value"}, // dot in option followed by =value
{"@<filename>"},
{"-option", "name", "p1:p2.."},
{"-All these non-options show launchers pass options as is to tool."},
{"-option"},
{"-option:sub"},
{"-option:sub-"},
{"-option", "<path>"},
{"-option", "<file>"},
{"-option", "<dir>"},
{"-option", "http://a/b/c/g;x?y#s"},
{"-option", "<html code>"},
{"-option", "name1:name2"},
{"-option", "3"},
{"option1", "-J-version", "option2"},
{"option1", "-J-version", "-J-XshowSettings:vm", "option2"},};
return;
}
// A tool which simulates com.sun.tools.javac.Main argument processing,
// intercepts options passed via the javac launcher.
// compile and jar Main.java into test.jar
}
}
}
// Return position of -J option or -1 is does not contain a -J option.
return i;
}
}
return -1;
}
/*
* Check that J options a) are not passed to tool, and b) do the right thing,
* that is, they should be passed to java launcher and work as expected.
*/
// Check -J-version options are not passed but do what they should.
throw new RuntimeException(
"failed: output should not contain option " + pat);
}
" should display a version string.");
}
" should have display VM settings.");
}
}
}
}
/*
* Feed each option pattern in optionPatterns array to javac launcher with
* checking program preempting javac. Check that option received by 'dummy'
* javac is the one passed on the command line.
*/
init();
int jpos = -1;
//Build a cmd string for output in results reporting.
}
case 1:
arg[0]);
break;
case 2:
break;
case 3:
break;
case 4:
break;
default:
break;
}
//-Joptions should not be passed to tool
if (jpos > -1) {
throw new RuntimeException(
"failed! Should not have passed -J option to tool.\n"
+ "CMD: " + cmdString);
}
} else {
//check that each non -J option was passed to tool.
throw new RuntimeException(
} else {
}
}
}
}
}
}
}