Skip to content

Commit

Permalink
[JENKINS-46724] - Get rid of the illegal Reflective operation in Laun…
Browse files Browse the repository at this point in the history
…cher.

IIUC it may prevent Java Web Start agents from starting up in Java 9.
Anyway, the reflection is not required anymore since Remoting requires Java 8
  • Loading branch information
oleg-nenashev committed Nov 15, 2017
1 parent 40def98 commit 8963035
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions src/main/java/hudson/remoting/Launcher.java
Expand Up @@ -25,6 +25,8 @@

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.remoting.Channel.Mode;

import java.io.Console;
import java.io.FileInputStream;
import java.io.UnsupportedEncodingException;
import java.nio.file.Path;
Expand Down Expand Up @@ -678,29 +680,19 @@ private void runWithStdinStdout() throws IOException, InterruptedException {
main(System.in, os, mode, ping, jarCache != null ? new FileSystemJarCache(jarCache,true) : null);
}

/**
* Checks if there is any {@link java.io.Console Console} object associated with JVM.
* If yes, prints a warning to STDOUT.
*/
private static void ttyCheck() {
try {
Method m = System.class.getMethod("console");
Object console = m.invoke(null);
if(console!=null) {
// we seem to be running from interactive console. issue a warning.
// but since this diagnosis could be wrong, go on and do what we normally do anyway. Don't exit.
System.out.println(
"WARNING: Are you running slave agent from an interactive console?\n" +
"If so, you are probably using it incorrectly.\n" +
"See http://wiki.jenkins-ci.org/display/JENKINS/Launching+slave.jar+from+from+console");
}
} catch (LinkageError e) {
// we are probably running on JDK5 that doesn't have System.console()
// we can't check
} catch (InvocationTargetException e) {
// this is impossible
throw new AssertionError(e);
} catch (NoSuchMethodException e) {
// must be running on JDK5
} catch (IllegalAccessException e) {
// this is impossible
throw new AssertionError(e);
final Console console = System.console();
if(console != null) {
// we seem to be running from interactive console. issue a warning.
// but since this diagnosis could be wrong, go on and do what we normally do anyway. Don't exit.
System.out.println(
"WARNING: Are you running slave agent from an interactive console?\n" +
"If so, you are probably using it incorrectly.\n" +
"See http://wiki.jenkins-ci.org/display/JENKINS/Launching+slave.jar+from+from+console");
}
}

Expand Down

0 comments on commit 8963035

Please sign in to comment.