From e510ab494b5c2e651d6f1710c233f0a4b61ebd07 Mon Sep 17 00:00:00 2001 From: jonas Date: Tue, 19 Mar 2024 22:36:47 +0100 Subject: [PATCH 1/7] chore: optimized main class grabbing Co-authored-by: @ScaredDev --- build.gradle | 2 +- .../javamoduleloader/module/Module.java | 5 +++-- .../javamoduleloader/module/SimpleModule.java | 16 +++++++++------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index 6272149..e72c8f9 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group 'de.interguess' -version '1.0-beta' +version '1.0.1-beta' repositories { mavenCentral() diff --git a/src/main/java/de/interguess/javamoduleloader/module/Module.java b/src/main/java/de/interguess/javamoduleloader/module/Module.java index 0f9081b..a8225d3 100644 --- a/src/main/java/de/interguess/javamoduleloader/module/Module.java +++ b/src/main/java/de/interguess/javamoduleloader/module/Module.java @@ -1,5 +1,6 @@ package de.interguess.javamoduleloader.module; +import de.interguess.javamoduleloader.exception.ModuleLoadException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -44,7 +45,7 @@ public interface Module { * @param requiredSuperClass the required superclass of the main class * @param mainClass the name of the main class * @return the main class of the module - * @throws ClassNotFoundException if the main class could not be found + * @throws ModuleLoadException if there was an error loading or verifying the main class */ - @NotNull Class getMainClassByName(@NotNull Class requiredSuperClass, @NotNull String mainClass) throws ClassNotFoundException; + @NotNull Class getMainClassByName(@NotNull Class requiredSuperClass, @NotNull String mainClass) throws ModuleLoadException; } \ No newline at end of file diff --git a/src/main/java/de/interguess/javamoduleloader/module/SimpleModule.java b/src/main/java/de/interguess/javamoduleloader/module/SimpleModule.java index 71c765f..679df2c 100644 --- a/src/main/java/de/interguess/javamoduleloader/module/SimpleModule.java +++ b/src/main/java/de/interguess/javamoduleloader/module/SimpleModule.java @@ -50,15 +50,17 @@ public SimpleModule(File file) throws ModuleLoadException { } @Override - public @NotNull Class getMainClassByName(@NotNull Class requiredSuperClass, @NotNull String mainClass) throws ClassNotFoundException { - Class clazz = classLoader.loadClass(mainClass); + public @NotNull Class getMainClassByName(@NotNull Class requiredSuperClass, @NotNull String mainClass) throws ModuleLoadException { + try { + Class clazz = classLoader.loadClass(mainClass); + + if (!requiredSuperClass.isAssignableFrom(clazz)) { + throw new ModuleLoadException("Class " + mainClass + " does not extend or implement " + requiredSuperClass.getName()); + } - if (clazz == null) { - throw new ClassNotFoundException("Class not found: " + mainClass); - } else if (!clazz.getSuperclass().equals(requiredSuperClass)) { - throw new ClassNotFoundException("Class " + mainClass + " does not implement " + requiredSuperClass.getName()); - } else { return (Class) clazz; + } catch (ClassNotFoundException e) { + throw new ModuleLoadException("Class not found: " + mainClass, e); } } } From a5836aa49f26a12461c2c22660ba0754b61986df Mon Sep 17 00:00:00 2001 From: JonasDevDE <73913242+JonasDevDE@users.noreply.github.com> Date: Sat, 23 Mar 2024 22:13:56 +0100 Subject: [PATCH 2/7] Create LICENSE Signed-off-by: JonasDevDE <73913242+JonasDevDE@users.noreply.github.com> --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6cd310d --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Interguess + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 66870ff593d8c511671dc4027f3a5f83446ff239 Mon Sep 17 00:00:00 2001 From: JonasDevDE <73913242+JonasDevDE@users.noreply.github.com> Date: Tue, 13 Aug 2024 13:03:30 +0200 Subject: [PATCH 3/7] Update README.md Signed-off-by: JonasDevDE <73913242+JonasDevDE@users.noreply.github.com> --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ac08ac5..a4f2e01 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Java Module loader is a framework to load .jar archives with Java modules and to ```gradle repositories { maven { - url 'https://repo.interguessweb.de/maven-public/' + url 'https://repo.interguess.de/maven-public/' } } ``` @@ -21,7 +21,7 @@ dependencies { interguess-repo - https://repo.interguessweb.de/maven-public/ + https://repo.interguess.de/maven-public/ ``` From c6de3ce09ce1e50b2193f447dc7771ba65f000f7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 19:07:24 +0000 Subject: [PATCH 4/7] Bump org.jetbrains:annotations from 24.1.0 to 25.0.0 Bumps [org.jetbrains:annotations](https://github.com/JetBrains/java-annotations) from 24.1.0 to 25.0.0. - [Release notes](https://github.com/JetBrains/java-annotations/releases) - [Changelog](https://github.com/JetBrains/java-annotations/blob/master/CHANGELOG.md) - [Commits](https://github.com/JetBrains/java-annotations/compare/24.1.0...25.0.0) --- updated-dependencies: - dependency-name: org.jetbrains:annotations dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e72c8f9..e7b89ee 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ repositories { } dependencies { - compileOnly 'org.jetbrains:annotations:24.1.0' + compileOnly 'org.jetbrains:annotations:25.0.0' } publishing { From f8b940be1983ddd1b0955ea16f041f33d79a981b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Oct 2024 19:34:08 +0000 Subject: [PATCH 5/7] Bump org.jetbrains:annotations from 25.0.0 to 26.0.0 Bumps [org.jetbrains:annotations](https://github.com/JetBrains/java-annotations) from 25.0.0 to 26.0.0. - [Release notes](https://github.com/JetBrains/java-annotations/releases) - [Changelog](https://github.com/JetBrains/java-annotations/blob/master/CHANGELOG.md) - [Commits](https://github.com/JetBrains/java-annotations/compare/25.0.0...26.0.0) --- updated-dependencies: - dependency-name: org.jetbrains:annotations dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e7b89ee..4f45730 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ repositories { } dependencies { - compileOnly 'org.jetbrains:annotations:25.0.0' + compileOnly 'org.jetbrains:annotations:26.0.0' } publishing { From 1941e5f4ef501f06b59da0d7814fbb462c9ed677 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 20:18:11 +0000 Subject: [PATCH 6/7] Bump org.jetbrains:annotations from 26.0.0 to 26.0.1 Bumps [org.jetbrains:annotations](https://github.com/JetBrains/java-annotations) from 26.0.0 to 26.0.1. - [Release notes](https://github.com/JetBrains/java-annotations/releases) - [Changelog](https://github.com/JetBrains/java-annotations/blob/master/CHANGELOG.md) - [Commits](https://github.com/JetBrains/java-annotations/compare/26.0.0...26.0.1) --- updated-dependencies: - dependency-name: org.jetbrains:annotations dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 4f45730..5593f26 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ repositories { } dependencies { - compileOnly 'org.jetbrains:annotations:26.0.0' + compileOnly 'org.jetbrains:annotations:26.0.1' } publishing { From 9250fc89f764e52365f6fb0da8c44484c3edbf20 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 22 Jan 2025 20:05:34 +0000 Subject: [PATCH 7/7] Bump org.jetbrains:annotations from 26.0.1 to 26.0.2 Bumps [org.jetbrains:annotations](https://github.com/JetBrains/java-annotations) from 26.0.1 to 26.0.2. - [Release notes](https://github.com/JetBrains/java-annotations/releases) - [Changelog](https://github.com/JetBrains/java-annotations/blob/master/CHANGELOG.md) - [Commits](https://github.com/JetBrains/java-annotations/compare/26.0.1...26.0.2) --- updated-dependencies: - dependency-name: org.jetbrains:annotations dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 5593f26..8a9f320 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ repositories { } dependencies { - compileOnly 'org.jetbrains:annotations:26.0.1' + compileOnly 'org.jetbrains:annotations:26.0.2' } publishing {