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.
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/
```
diff --git a/build.gradle b/build.gradle
index 6272149..8a9f320 100644
--- a/build.gradle
+++ b/build.gradle
@@ -4,14 +4,14 @@ plugins {
}
group 'de.interguess'
-version '1.0-beta'
+version '1.0.1-beta'
repositories {
mavenCentral()
}
dependencies {
- compileOnly 'org.jetbrains:annotations:24.1.0'
+ compileOnly 'org.jetbrains:annotations:26.0.2'
}
publishing {
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);
}
}
}