asdru
asdru
JCHJava Community | Help. Code. Learn.
Created by asdru on 2/1/2025 in #java-help
Java classfile api example
import java.io.File;
import java.io.IOException;
import java.lang.classfile.ClassFile;
import java.lang.classfile.FieldModel;
import java.lang.classfile.MethodModel;
import java.nio.file.Files;


void main() {

var classModel = ClassFile.of().parse(getGivenClassBytes("/src/main/java/Person"));
for (var classElement : classModel) {
switch (classElement) {
case MethodModel mm ->
System.out.printf("Method name %s type %s%n", mm.methodName().stringValue(), mm.methodType().stringValue());
case FieldModel fm ->
System.out.printf("Field name %s type %s%n", fm.fieldName().stringValue(), fm.fieldType().stringValue());

default -> {
}
}
}
}

private static byte[] getGivenClassBytes(final String className) {
try {
var path = System.getProperty("user.dir") + "/" + className + ".class";
File file = new File(path);
return Files.readAllBytes(file.toPath());
} catch (IOException ioe) {
throw new RuntimeException(ioe.getMessage());
}
}
import java.io.File;
import java.io.IOException;
import java.lang.classfile.ClassFile;
import java.lang.classfile.FieldModel;
import java.lang.classfile.MethodModel;
import java.nio.file.Files;


void main() {

var classModel = ClassFile.of().parse(getGivenClassBytes("/src/main/java/Person"));
for (var classElement : classModel) {
switch (classElement) {
case MethodModel mm ->
System.out.printf("Method name %s type %s%n", mm.methodName().stringValue(), mm.methodType().stringValue());
case FieldModel fm ->
System.out.printf("Field name %s type %s%n", fm.fieldName().stringValue(), fm.fieldType().stringValue());

default -> {
}
}
}
}

private static byte[] getGivenClassBytes(final String className) {
try {
var path = System.getProperty("user.dir") + "/" + className + ".class";
File file = new File(path);
return Files.readAllBytes(file.toPath());
} catch (IOException ioe) {
throw new RuntimeException(ioe.getMessage());
}
}
i got this basic example but i still cant get it to print the contents of the function like
func @"sub" @loc="19:5:file:/.../ExpressionGraphs.java" (%0 : double, %1 : double)double -> {
%2 : Var<double> = var %0 @"a" @loc="19:5";
%3 : Var<double> = var %1 @"b" @loc="19:5";
%4 : double = var.load %2 @loc="21:16";
%5 : double = var.load %3 @loc="21:20";
%6 : double = sub %4 %5 @loc="21:16";
return %6 @loc="21:9";
};
func @"sub" @loc="19:5:file:/.../ExpressionGraphs.java" (%0 : double, %1 : double)double -> {
%2 : Var<double> = var %0 @"a" @loc="19:5";
%3 : Var<double> = var %1 @"b" @loc="19:5";
%4 : double = var.load %2 @loc="21:16";
%5 : double = var.load %3 @loc="21:20";
%6 : double = sub %4 %5 @loc="21:16";
return %6 @loc="21:9";
};
10 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 1/27/2025 in #java-help
have two different projects open on intellij
oh im using maven, ill look into that
8 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 1/27/2025 in #java-help
have two different projects open on intellij
wait is that literally what the test folder is for?
8 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 1/8/2025 in #java-help
line numbers arent visible in CodeArea
oh ok i just noticed that it works if i create a new tab, but it doesnt when i open a file from the sidebar
5 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 1/4/2025 in #java-help
better data structure to handle entity stats
i guess i could have a class that stores the single stats and add from there but idk
9 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 1/4/2025 in #java-help
better data structure to handle entity stats
i could but i plan on adding more in the future
9 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 12/22/2024 in #java-help
make github actions build artifact public
- name: Build
run: echo ${{ github.sha }} > Release.txt
- name: Test
run: cat Release.txt
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: Release.txt
- name: Build
run: echo ${{ github.sha }} > Release.txt
- name: Test
run: cat Release.txt
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: Release.txt
this part?
25 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 12/22/2024 in #java-help
make github actions build artifact public
name: Java CI with Maven

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '22'
distribution: 'oracle'
- run: mvn --batch-mode --update-snapshots verify
- run: mkdir staging && cp target/*.jar staging
- uses: actions/upload-artifact@v4
with:
name: Runnable Jar
path: staging
name: Java CI with Maven

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '22'
distribution: 'oracle'
- run: mvn --batch-mode --update-snapshots verify
- run: mkdir staging && cp target/*.jar staging
- uses: actions/upload-artifact@v4
with:
name: Runnable Jar
path: staging
how can i merge it with this 😅
25 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 12/22/2024 in #java-help
make github actions build artifact public
yeah that'd be ideal, i tried messing with the yml file but could figure out how
25 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 12/22/2024 in #java-help
make github actions build artifact public
push->build jar->upload jar as release
25 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 12/22/2024 in #java-help
make github actions build artifact public
i know how to do that manually, but i was hoping to find a way to automate the process?
25 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 12/22/2024 in #java-help
make github actions build artifact public
I mean change the yaml file so that it automatically publishes the artifact as a release
25 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 12/22/2024 in #java-help
make github actions build artifact public
Ohh ok But what if I wanted to make it a release
25 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 12/22/2024 in #java-help
make github actions build artifact public
25 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 12/19/2024 in #java-help
build javaFX jar from github via maven
i checked and have all the required dependencies in my pom.xml file, so i cant tell what im doing wrong here
7 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 10/24/2024 in #java-help
Optimizing draw function for texured triangle
thanks for the advice!
20 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 10/24/2024 in #java-help
Optimizing draw function for texured triangle
but i should test it further
20 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 10/24/2024 in #java-help
Optimizing draw function for texured triangle
its not super slow so far i have 50 triangles on my screen and its still running at 60fps
20 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 10/24/2024 in #java-help
Optimizing draw function for texured triangle
i tried lwjgl too but didn't like it since ur working with ints
20 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 10/24/2024 in #java-help
Optimizing draw function for texured triangle
lets say its a personal challenge and im trying to learn 3d graphics
20 replies