Last active
January 31, 2023 12:57
-
-
Save dmikurube/35e95c45e5cd511484b8fe982d1469ee to your computer and use it in GitHub Desktop.
NoClassDefFoundError
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugins { | |
id "java" | |
id "application" | |
} | |
configurations { | |
compileClasspath.resolutionStrategy.activateDependencyLocking() | |
runtimeClasspath.resolutionStrategy.activateDependencyLocking() | |
} | |
repositories { | |
mavenCentral() | |
} | |
java { | |
toolchain { | |
languageVersion = JavaLanguageVersion.of(8) | |
} | |
} | |
tasks.withType(JavaCompile) { | |
options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked" | |
options.encoding = "UTF-8" | |
} | |
sourceSets { | |
main { | |
java { | |
srcDir '.' | |
} | |
} | |
} | |
dependencies { | |
compileOnly "org.msgpack:msgpack-core:0.8.24" | |
} | |
application { | |
mainClass = "Main" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(final String[] args) { | |
System.out.println("#1"); | |
Sub.safe(); | |
Sub.unsafe1(null); | |
Sub.unsafe2(null); | |
Sub.unsafe3(null); | |
Sub.unsafe4(null); | |
System.out.println("#2"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.msgpack.value.Value; | |
public class Sub { | |
public static void safe() { | |
System.out.println("Safe"); | |
} | |
public static void unsafe1(final Value value) { | |
System.out.println("Unsafe1"); | |
} | |
public static void unsafe2(final Value value) { | |
System.out.println("Unsafe2"); | |
if (value == null) { | |
System.out.println("null"); | |
} else { | |
System.out.println(value.toString()); | |
} | |
} | |
public static void unsafe3(final Value value) { | |
System.out.println("Unsafe3"); | |
try { | |
System.out.println(value.toJson()); | |
} catch (final Throwable ex) { | |
ex.printStackTrace(System.out); | |
} | |
} | |
public static void unsafe4(final Value value) { | |
System.out.println("Unsafe4"); | |
try { | |
System.out.println(value.toString()); | |
} catch (final Throwable ex) { | |
ex.printStackTrace(System.out); | |
} | |
} | |
} |
Author
dmikurube
commented
Jan 31, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment