2222import java .net .MalformedURLException ;
2323import java .net .URL ;
2424import java .util .ArrayList ;
25- import java .util .Arrays ;
2625import java .util .List ;
2726import java .util .StringTokenizer ;
2827import java .util .logging .Level ;
@@ -40,70 +39,16 @@ public class ClassPathUtils {
4039 private static final String RUNTIME_IMPL_PROPERTY = "classpath.runtime-impl" ;
4140 private static final String RUNTIME_SHARED_PROPERTY = "classpath.runtime-shared" ;
4241 private static final String PREBUNDLED_PROPERTY = "classpath.prebundled" ;
43- private static final String API_PROPERTY = "classpath.api-map" ;
4442 private static final String CONNECTOR_J_PROPERTY = "classpath.connector-j" ;
45- private static final String APPENGINE_API_LEGACY_PROPERTY = "classpath.appengine-api-legacy" ;
46- private static final String LEGACY_PROPERTY = "classpath.legacy" ;
4743 // Cannot use Guava library in this classloader.
4844 private static final String PATH_SEPARATOR = System .getProperty ("path.separator" );
4945
5046 private final File root ;
51- private File frozenApiJarFile ;
5247
5348 public ClassPathUtils () {
5449 this (null );
5550 }
56-
57- public ClassPathUtils (File root ) {
58-
59- String runtimeBase = System .getProperty (RUNTIME_BASE_PROPERTY );
60- if (runtimeBase == null ) {
61- throw new RuntimeException ("System property not defined: " + RUNTIME_BASE_PROPERTY );
62- }
63- this .root = root ;
64-
65- if (!new File (runtimeBase , "java_runtime_launcher" ).exists ()) {
66- initForJava11OrAbove (runtimeBase );
67- return ;
68- }
69-
70- String profilerJar = null ;
71- if (System .getenv ("GAE_PROFILER_MODE" ) != null ) {
72- profilerJar = "profiler.jar" ; // Close source, not in Maven.;
73- logger .log (Level .INFO , "AppEngine profiler enabled." );
74- }
75- List <String > runtimeClasspathEntries =
76- Arrays .asList ("jars/runtime-impl-jetty9.jar" , profilerJar );
77-
78- String runtimeClasspath =
79- runtimeClasspathEntries .stream ()
80- .filter (t -> t != null )
81- .map (s -> runtimeBase + "/" + s )
82- .collect (joining (PATH_SEPARATOR ));
83-
84- if (System .getProperty (RUNTIME_IMPL_PROPERTY ) != null ) {
85- // Prepend existing value, only used in our tests.
86- runtimeClasspath =
87- System .getProperty (RUNTIME_IMPL_PROPERTY ) + PATH_SEPARATOR + runtimeClasspath ;
88- }
89- // Keep old properties for absolute compatibility if ever some public apps depend on them:
90- System .setProperty (RUNTIME_IMPL_PROPERTY , runtimeClasspath );
91- logger .log (Level .INFO , "Using runtime classpath: " + runtimeClasspath );
92-
93- // The frozen API jar we must use for ancient customers still relying on the obsolete feature
94- // that when deploying with api_version: 1.0 in generated app.yaml
95- // we need to add our own legacy jar.
96- frozenApiJarFile = new File (new File (root , runtimeBase ), "/appengine-api.jar" );
97- System .setProperty (RUNTIME_SHARED_PROPERTY , runtimeBase + "/jars/runtime-shared-jetty9.jar" );
98- System .setProperty (API_PROPERTY , "1.0=" + runtimeBase + "/jars/appengine-api-1.0-sdk.jar" );
99- System .setProperty (
100- APPENGINE_API_LEGACY_PROPERTY , runtimeBase + "/jars/appengine-api-legacy.jar" );
101- System .setProperty (CONNECTOR_J_PROPERTY , runtimeBase + "/jdbc-mysql-connector.jar" );
102- System .setProperty (PREBUNDLED_PROPERTY , runtimeBase + "/conscrypt.jar" );
103- System .setProperty (LEGACY_PROPERTY , runtimeBase + "/legacy.jar" );
104- }
105-
106- /**
51+ /**
10752 * Initializes runtime classpath properties for Java 11 and newer runtimes based on system
10853 * properties that indicate which Jakarta EE version and Jetty version to use.
10954 *
@@ -128,9 +73,15 @@ public ClassPathUtils(File root) {
12873 * <li>If EE6 is active (default), Jetty 9.4 is used with {@code runtime-shared-jetty9.jar}.
12974 * </ul>
13075 *
131- * @param runtimeBase The base directory for runtime jars.
13276 */
133- private void initForJava11OrAbove (String runtimeBase ) {
77+
78+ public ClassPathUtils (File root ) {
79+
80+ String runtimeBase = System .getProperty (RUNTIME_BASE_PROPERTY );
81+ if (runtimeBase == null ) {
82+ throw new RuntimeException ("System property not defined: " + RUNTIME_BASE_PROPERTY );
83+ }
84+ this .root = root ;
13485 /*
13586 New content is very simple now (from maven jars):
13687 ls blaze-bin/java/com/google/apphosting/runtime_java11/deployment_java11
@@ -223,7 +174,6 @@ New content is very simple now (from maven jars):
223174 System .setProperty (RUNTIME_IMPL_PROPERTY , runtimeClasspath );
224175 logger .log (Level .INFO , "Using runtime classpath: " + runtimeClasspath );
225176
226- frozenApiJarFile = new File (runtimeBase , "/appengine-api-1.0-sdk.jar" );
227177 }
228178
229179 public URL [] getRuntimeImplUrls () {
@@ -252,34 +202,6 @@ public URL[] getConnectorJUrls() {
252202 }
253203 }
254204
255- /**
256- * Returns the URLs for legacy jars. This may be empty or it may be one or more jars that contain
257- * classes like {@code com.google.appengine.repackaged.org.joda.Instant}, the old form of
258- * repackaging. We've switched to classes like {@code
259- * com.google.appengine.repackaged.org.joda.$Instant}, with a {@code $}, but this jar can
260- * optionally be added to an app's classpath if it is referencing the old names. Other legacy
261- * classes, unrelated to repackaging, may also appear in these jars.
262- */
263- public URL [] getLegacyJarUrls () {
264- String path = System .getProperty (LEGACY_PROPERTY );
265- if (path == null ) {
266- return new URL [0 ];
267- } else {
268- return parseClasspath (path );
269- }
270- }
271-
272- /** Returns a {@link File} for the frozen old API jar, */
273- public File getFrozenApiJar () {
274- return frozenApiJarFile ;
275- }
276-
277- @ Nullable
278- public File getAppengineApiLegacyJar () {
279- String filename = System .getProperty (APPENGINE_API_LEGACY_PROPERTY );
280- return filename == null ? null : new File (root , filename );
281- }
282-
283205 /**
284206 * Parse the specified string into individual files (using the machine's path separator) and
285207 * return an array containing a {@link URL} object representing each file.
0 commit comments