From 4d806d452ff3de92ac100e7ea11dd0466dbaf55b Mon Sep 17 00:00:00 2001 From: Konrad `ktoso` Malawski Date: Tue, 10 Dec 2024 13:51:37 +0900 Subject: [PATCH] Cleanup: Remove not used SystemClassLoaderUnsafe --- .../dependencies/SystemClassLoaderUnsafe.java | 46 ------------------- .../swift-java.config | 4 -- 2 files changed, 50 deletions(-) delete mode 100644 JavaKit/src/main/java/org/swift/javakit/dependencies/SystemClassLoaderUnsafe.java diff --git a/JavaKit/src/main/java/org/swift/javakit/dependencies/SystemClassLoaderUnsafe.java b/JavaKit/src/main/java/org/swift/javakit/dependencies/SystemClassLoaderUnsafe.java deleted file mode 100644 index d8d4f64a..00000000 --- a/JavaKit/src/main/java/org/swift/javakit/dependencies/SystemClassLoaderUnsafe.java +++ /dev/null @@ -1,46 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2024 Apple Inc. and the Swift.org project authors -// Licensed under Apache License v2.0 -// -// See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift.org project authors -// -// SPDX-License-Identifier: Apache-2.0 -// -//===----------------------------------------------------------------------===// - -package org.swift.javakit.dependencies; - -import java.io.File; -import java.net.URL; -import java.net.URLClassLoader; - -public final class SystemClassLoaderUnsafe { - - private SystemClassLoaderUnsafe() {} - - /** - * Use internal methods to add a path to the system classloader. - * If this ever starts throwing in new JDK versions, we may need to abandon this technique. - * - * @param path path to add to the current system classloader. - */ - public static void addPath(String path) { - try { - var url = new File(path).toURI().toURL(); - var urlClassLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); - var method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); - method.setAccessible(true); - method.invoke(urlClassLoader, url); - } catch (Throwable ex) { - throw new RuntimeException("Unable to add path to system class loader! " + - "This is not supported API and may indeed start failing in the future. " + - "If/when this happens, we have to change the bootstrap logic to instead " + - "create a new JVM with the new bootstrap classpath, " + - "rather than add paths to the existing one.", ex); - } - } -} diff --git a/Sources/JavaKitDependencyResolver/swift-java.config b/Sources/JavaKitDependencyResolver/swift-java.config index d2d9f448..6ea5aa87 100644 --- a/Sources/JavaKitDependencyResolver/swift-java.config +++ b/Sources/JavaKitDependencyResolver/swift-java.config @@ -2,8 +2,4 @@ "dependencies": [ ":JavaKit", ] - , - "__classes": { - "org.swift.javakit.dependencies.DependencyResolver": "DependencyResolver" - } }