Index: src/test/java/com/sun/enterprise/admin/launcher/GFLauncherTest.java =================================================================== --- src/test/java/com/sun/enterprise/admin/launcher/GFLauncherTest.java (revision 52041) +++ src/test/java/com/sun/enterprise/admin/launcher/GFLauncherTest.java (working copy) @@ -108,11 +108,11 @@ public void test2() throws GFLauncherException, MiniXmlParserException { info.setDomainName("domain1"); launcher.launch(); - List cmdline = launcher.getCommandLine(); + List cmdline = launcher.getJvmOptions(); assertTrue(cmdline.contains("-XX:+UnlockDiagnosticVMOptions")); // 0 --> java, 1 --> "-cp" 2 --> the classpath, 3 -->first arg - assertEquals(cmdline.get(3), "-XX:+UnlockDiagnosticVMOptions"); + assertEquals(cmdline.get(0), "-XX:+UnlockDiagnosticVMOptions"); /* Too noisy, todo figure out how to get it into the test report System.out.println("COMMANDLINE:"); @@ -130,7 +130,7 @@ public void test3() throws GFLauncherException, MiniXmlParserException { info.setDomainName("domain2"); launcher.launch(); - List cmdline = launcher.getCommandLine(); + List cmdline = launcher.getJvmOptions(); assertFalse(cmdline.contains("-XX:+UnlockDiagnosticVMOptions")); /* Index: src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java =================================================================== --- src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java (revision 52041) +++ src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java (working copy) @@ -189,7 +188,9 @@ GFLauncherLogger.addLogFileHandler(logFilename, info); setJavaExecutable(); setClasspath(); + setJvmOptions(); setCommandLine(); + logJvmOptions(); logCommandLine(); // if no element, we need to upgrade this domain needsAutoUpgrade = !parser.hasNetworkConfig(); @@ -423,6 +427,11 @@ return commandLine; } + public final List getJvmOptions() { + return jvmOptionsList; + } + + final long getStartTime() { return startTime; } @@ -541,24 +543,29 @@ cmdLine.add("-DWALL_CLOCK_START=" + CLIStartTime); } - if (jvmOptions != null) - addIgnoreNull(cmdLine, jvmOptions.toStringArray()); - GFLauncherNativeHelper nativeHelper = new GFLauncherNativeHelper(info, javaConfig, jvmOptions, profiler); addIgnoreNull(cmdLine, nativeHelper.getCommands()); addIgnoreNull(cmdLine, getMainClass()); try { addIgnoreNull(cmdLine, getInfo().getArgsAsList()); - } - catch (GFLauncherException gfle) { + } catch (GFLauncherException gfle) { throw gfle; - } - catch (Exception e) { + } catch (Exception e) { //harmless } } + void setJvmOptions() throws GFLauncherException { + List jvmOpts = getJvmOptions(); + jvmOpts.clear(); + + if (jvmOptions != null) + addIgnoreNull(jvmOpts, jvmOptions.toStringArray()); + + } + + @@ -851,6 +852,19 @@ } } + void logJvmOptions() { + StringBuilder sb = new StringBuilder(); + for (String s : jvmOptionsList) { + // newline before the first line... + sb.append(NEWLINE); + sb.append(s); + } + if (!isFakeLaunch()) { + GFLauncherLogger.info("commandline", sb.toString()); + } + } + + String getClasspath() { return classpath; } @@ -912,22 +926,21 @@ System.out.println(strings.get("ssh", sname)); try { System.in.close(); + } catch (Exception e) { // ignore } - catch (Exception e) { // ignore - } try { System.err.close(); + } catch (Exception e) { // ignore } - catch (Exception e) { // ignore - } try { System.out.close(); + } catch (Exception e) { // ignore } - catch (Exception e) { // ignore - } } } + private List commandLine = new ArrayList(); + private List jvmOptionsList = new ArrayList(); private GFLauncherInfo info; private Map asenvProps; private JavaConfig javaConfig;