1
1
/*
2
- * Copyright 2000-2016 JetBrains s.r.o.
2
+ * Copyright 2000-2017 JetBrains s.r.o.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
22
22
import com .intellij .execution .process .ProcessHandler ;
23
23
import com .intellij .openapi .application .PathManager ;
24
24
import com .intellij .openapi .diagnostic .Logger ;
25
+ import com .intellij .openapi .projectRoots .JavaSdkVersion ;
25
26
import com .intellij .openapi .projectRoots .ex .JavaSdkUtil ;
26
27
import com .intellij .openapi .util .text .StringUtil ;
27
28
import com .intellij .rt .execution .application .AppMain ;
@@ -37,35 +38,31 @@ public ProcessProxy createCommandLineProxy(JavaCommandLine javaCmdLine) throws E
37
38
String mainClass = javaParameters .getMainClass ();
38
39
39
40
if (ourMayUseLauncher && mainClass != null ) {
40
- String moduleName = javaParameters . getModuleName ();
41
- String rtJarPath = JavaSdkUtil . getIdeaRtJarPath ( );
41
+ try {
42
+ ProcessProxyImpl proxy = new ProcessProxyImpl ( StringUtil . getShortName ( mainClass ) );
42
43
43
- if ( moduleName == null || new File ( rtJarPath ). isFile ()) {
44
- try {
45
- ProcessProxyImpl proxy = new ProcessProxyImpl ( StringUtil . getShortName ( mainClass ) );
44
+ String rtJarPath = JavaSdkUtil . getIdeaRtJarPath ();
45
+ String port = String . valueOf ( proxy . getPortNumber ());
46
+ String binPath = PathManager . getBinPath ( );
46
47
47
- String port = String .valueOf (proxy .getPortNumber ());
48
- String binPath = PathManager .getBinPath ();
49
-
50
- if (moduleName == null ) {
51
- JavaSdkUtil .addRtJar (javaParameters .getClassPath ());
52
-
53
- ParametersList vmParametersList = javaParameters .getVMParametersList ();
54
- vmParametersList .defineProperty (AppMain .LAUNCHER_PORT_NUMBER , port );
55
- vmParametersList .defineProperty (AppMain .LAUNCHER_BIN_PATH , binPath );
48
+ if (new File (rtJarPath ).isFile () && JavaSdkUtil .isAtLeast (javaParameters .getJdk (), JavaSdkVersion .JDK_1_5 )) {
49
+ javaParameters .getVMParametersList ().add ("-javaagent:" + rtJarPath + '=' + port + ':' + binPath );
50
+ }
51
+ else {
52
+ JavaSdkUtil .addRtJar (javaParameters .getClassPath ());
56
53
57
- javaParameters .getProgramParametersList ().prepend (mainClass );
58
- javaParameters .setMainClass (AppMain .class .getName ());
59
- }
60
- else {
61
- javaParameters .getVMParametersList ().add ("-javaagent:" + rtJarPath + '=' + port + ':' + binPath );
62
- }
54
+ ParametersList vmParametersList = javaParameters .getVMParametersList ();
55
+ vmParametersList .defineProperty (AppMain .LAUNCHER_PORT_NUMBER , port );
56
+ vmParametersList .defineProperty (AppMain .LAUNCHER_BIN_PATH , binPath );
63
57
64
- return proxy ;
65
- }
66
- catch (Exception e ) {
67
- Logger .getInstance (ProcessProxy .class ).warn (e );
58
+ javaParameters .getProgramParametersList ().prepend (mainClass );
59
+ javaParameters .setMainClass (AppMain .class .getName ());
68
60
}
61
+
62
+ return proxy ;
63
+ }
64
+ catch (Exception e ) {
65
+ Logger .getInstance (ProcessProxy .class ).warn (e );
69
66
}
70
67
}
71
68
0 commit comments