Tyranobast
Tyranobast
JCHJava Community | Help. Code. Learn.
Created by Tyranobast on 11/10/2024 in #java-help
Creating a gradle plugin for a custom JVM language
Hi! I'm currently struggling making a gradle plugin for a simple JVM language I've made. The goal is to make my language buildable using gradle with the least user configuration as possible. I already read this article on sorcersoft, this one on baeldung and this one from dzone. I also read the official gradle documentation. However, I did not find any explanation on how I could create a gradle plugin that adds some custom language support (library management, compilation and execution). My custom language has a compiler, which can be executed from command line (or from java/kotlin if needed). Do you know any resource I could access to learn more about it (documentation, articles, forum, communities) ? Or can you directly explain me how it works ? Please ping me on reply. Thanks!
7 replies
JCHJava Community | Help. Code. Learn.
Created by Tyranobast on 6/8/2023 in #java-help
Java 1.8 ASM modified code throws NoSuchFieldError
Hi! I use ASM to modify this code:
private Launch() {
URLClassLoader ucl = (URLClassLoader)this.getClass().getClassLoader();
classLoader = new LaunchClassLoader(ucl.getURLs());
blackboard = new HashMap();
Thread.currentThread().setContextClassLoader(classLoader);
}
private Launch() {
URLClassLoader ucl = (URLClassLoader)this.getClass().getClassLoader();
classLoader = new LaunchClassLoader(ucl.getURLs());
blackboard = new HashMap();
Thread.currentThread().setContextClassLoader(classLoader);
}
into
private Launch() {
URLClassLoader ucl = (URLClassLoader)this.getClass().getClassLoader();
classLoader = new CustomLaunchClassLoader(ucl.getURLs());
blackboard = new HashMap();
Thread.currentThread().setContextClassLoader(classLoader);
}
private Launch() {
URLClassLoader ucl = (URLClassLoader)this.getClass().getClassLoader();
classLoader = new CustomLaunchClassLoader(ucl.getURLs());
blackboard = new HashMap();
Thread.currentThread().setContextClassLoader(classLoader);
}
but when I execute it, it throws a NoSuchFieldError on the classLoader field. classLoader is a private static field.
7 replies
JCHJava Community | Help. Code. Learn.
Created by Tyranobast on 5/28/2023 in #java-help
ASM : Return a value
Hi. How, with ASM MethodVisitor, can I set the value my method returns ?
13 replies
JCHJava Community | Help. Code. Learn.
Created by Tyranobast on 10/31/2022 in #java-help
Looking for file format
Hi! I'm looking for a fast file format that can store large amount of small data. I want it to : - have a java way to read and write it - store 12 bytes as the key and a float as the value - store over 800 000 000 row - not be too slow to write - be fast to find keys, and its associated value
8 replies
JCHJava Community | Help. Code. Learn.
Created by Tyranobast on 10/19/2022 in #java-help
what does byte[] do while unzipping file ?
public static String unzip(File source) { ByteArrayOutputStream output = new ByteArrayOutputStream(); try (GZIPInputStream gis = new GZIPInputStream(new FileInputStream(source))) {
byte[] buffer = new byte[1024];
int len; while ((len = gis.read(buffer)) > 0) { output.write(buffer, 0, len); } } catch (IOException e) { e.printStackTrace(); } return output.toString(StandardCharsets.UTF_8); }
public static String unzip(File source) { ByteArrayOutputStream output = new ByteArrayOutputStream(); try (GZIPInputStream gis = new GZIPInputStream(new FileInputStream(source))) {
byte[] buffer = new byte[1024];
int len; while ((len = gis.read(buffer)) > 0) { output.write(buffer, 0, len); } } catch (IOException e) { e.printStackTrace(); } return output.toString(StandardCharsets.UTF_8); }
This code gets the string contained in a zim file. What does the byte[] buffer = new byte[1024]; do ? Why its size is 1024 ?
11 replies
JCHJava Community | Help. Code. Learn.
Created by Tyranobast on 10/13/2022 in #java-help
image generation from 3d points
Hi! How can I create an image from 3D points in java ? For example : I have two "pixels" : A={5,5,5} and its color is red. B={7,3,1} and its color is blue. I want to generate a image like if I am watching my points from a specific point with a specified angle and direction. What must I use to do it ? And how can I do it ?
4 replies