1616
1717package com .google .appengine .tools ;
1818
19+ import static com .google .common .base .StandardSystemProperty .JAVA_CLASS_PATH ;
1920import static com .google .common .base .StandardSystemProperty .JAVA_HOME ;
21+ import static com .google .common .base .StandardSystemProperty .JAVA_SPECIFICATION_VERSION ;
2022import static com .google .common .base .StandardSystemProperty .OS_NAME ;
23+ import static com .google .common .base .StandardSystemProperty .USER_DIR ;
2124
2225import com .google .appengine .tools .development .DevAppServerMain ;
2326import com .google .apphosting .utils .config .AppEngineConfigException ;
@@ -95,19 +98,6 @@ public class KickStart {
9598 private static final String SDK_ROOT_FLAG = "--sdk_root" ;
9699 private static final String SDK_ROOT_ERROR_MESSAGE = SDK_ROOT_FLAG + "=<path> expected" ;
97100
98- private static final String ENABLE_JACOCO_FLAG = "--enable_jacoco" ;
99- private static final String ENABLE_JACOCO_ERROR_MESSAGE =
100- ENABLE_JACOCO_FLAG + "=true|false expected." ;
101- private static final String JACOCO_AGENT_JAR_FLAG = "--jacoco_agent_jar" ;
102- private static final String JACOCO_AGENT_JAR_ERROR_MESSAGE =
103- JACOCO_AGENT_JAR_FLAG + "=<path> expected." ;
104- private static final String JACOCO_AGENT_ARGS_FLAG = "--jacoco_agent_args" ;
105- private static final String JACOCO_AGENT_ARGS_ERROR_MESSAGE =
106- JACOCO_AGENT_ARGS_FLAG + "=<jacoco agent args> expected." ;
107- private static final String JACOCO_EXEC_FLAG = "--jacoco_exec" ;
108- private static final String JACOCO_EXEC_ERROR_MESSAGE =
109- JACOCO_EXEC_FLAG + "=<path> expected." ;
110-
111101 private Process serverProcess = null ;
112102
113103 static class AppEnvironment {
@@ -136,10 +126,6 @@ private KickStart(String[] args) {
136126
137127 List <String > jvmArgs = new ArrayList <>();
138128 ArrayList <String > appServerArgs = new ArrayList <>();
139- boolean enableJacoco = false ;
140- String jacocoAgentJarArg = null ;
141- String jacocoAgentArgs = "" ;
142- String jacocoExecArg = "jacoco.exec" ;
143129
144130 List <String > command = builder .command ();
145131 command .add (javaExe );
@@ -160,14 +146,6 @@ private KickStart(String[] args) {
160146 } else if (args [i ].startsWith (START_ON_FIRST_THREAD_FLAG )) {
161147 startOnFirstThread =
162148 Boolean .parseBoolean (extractValue (args [i ], START_ON_FIRST_THREAD_ERROR_MESSAGE ));
163- } else if (args [i ].startsWith (ENABLE_JACOCO_FLAG )) {
164- enableJacoco = "true" .equals (extractValue (args [i ], ENABLE_JACOCO_ERROR_MESSAGE ));
165- } else if (args [i ].startsWith (JACOCO_AGENT_JAR_FLAG )) {
166- jacocoAgentJarArg = extractValue (args [i ], JACOCO_AGENT_JAR_ERROR_MESSAGE );
167- } else if (args [i ].startsWith (JACOCO_AGENT_ARGS_FLAG )) {
168- jacocoAgentArgs = extractValue (args [i ], JACOCO_AGENT_ARGS_ERROR_MESSAGE );
169- } else if (args [i ].startsWith (JACOCO_EXEC_FLAG )) {
170- jacocoExecArg = extractValue (args [i ], JACOCO_EXEC_ERROR_MESSAGE );
171149 } else if (args [i ].equals ("--test_mode" )) {
172150 testMode = true ;
173151 } else if (entryClass == null ) {
@@ -202,10 +180,19 @@ private KickStart(String[] args) {
202180 // For more details, see http://b/issue?id=1709075.
203181 jvmArgs .add ("-XstartOnFirstThread" );
204182 }
183+ if (!JAVA_SPECIFICATION_VERSION .value ().equals ("1.8" )) {
184+ // Java11 or later need more flags:
185+ jvmArgs .add ("--add-opens" );
186+ jvmArgs .add ("java.base/java.net=ALL-UNNAMED" );
187+ jvmArgs .add ("--add-opens" );
188+ jvmArgs .add ("java.base/sun.net.www.protocol.http=ALL-UNNAMED" );
189+ jvmArgs .add ("--add-opens" );
190+ jvmArgs .add ("java.base/sun.net.www.protocol.https=ALL-UNNAMED" );
191+ }
205192
206193 // Whatever classpath we were invoked with might have been relative.
207194 // We make all paths in the classpath absolute.
208- String classpath = System . getProperty ( "java.class.path" );
195+ String classpath = JAVA_CLASS_PATH . value ( );
209196 if (classpath == null ) {
210197 throw new IllegalArgumentException ("classpath must not be null" );
211198 }
@@ -256,24 +243,13 @@ private KickStart(String[] args) {
256243 }
257244 jvmArgs .add ("-Dfile.encoding=" + encoding );
258245
259- if (enableJacoco ) {
260- jvmArgs .add ("-D--enable_all_permissions=true" );
261- String jacocoAgentJar = new File (jacocoAgentJarArg ).getAbsolutePath ();
262- if (!jacocoAgentArgs .isEmpty ()) {
263- jacocoAgentArgs = jacocoAgentArgs + "," ;
264- }
265- jacocoAgentArgs += "destfile=" + new File (jacocoExecArg ).getAbsolutePath ();
266- jvmArgs .add ("-javaagent:" + jacocoAgentJar + "=" + jacocoAgentArgs );
267- }
268-
269246 // Build up the command
270247 command .addAll (jvmArgs );
271248 command .add ("-classpath" );
272249 command .add (newClassPath .toString ());
273250 command .add (entryClass );
274251 // Pass the current working directory so relative files can be interpreted the natural way.
275- command .add ("--property=kickstart.user.dir=" + System .getProperty ("user.dir" ));
276- command .add ("--no_java_agent" );
252+ command .add ("--property=kickstart.user.dir=" + USER_DIR .value ());
277253
278254 command .addAll (absoluteAppServerArgs );
279255 // Setup environment variables.
0 commit comments