GithubHelp home page GithubHelp logo

Running skija with Java 8 about skija HOT 18 CLOSED

jetbrains avatar jetbrains commented on May 22, 2024
Running skija with Java 8

from skija.

Comments (18)

Glavo avatar Glavo commented on May 22, 2024 2

@Jojal @yuhailong626 @Magneticflux @Sm0keySa1m0n @luojinrong @Sculas

HumbleUI/Skija has provided Java 8 support since 0.109.0.

from skija.

Jojal avatar Jojal commented on May 22, 2024 1

Just because of legacy :) I will take time to upgrade my app to java 11 but for huge application it's not so easy to do it unfortunately. That is why, it would have been easier if Skija could work directly with Java 8 in my case.

But it's now good to know that it can works with Java 8.
Thanks again for your help.
And really good job with Skija. Was waiting for that since a long time 👍

from skija.

tonsky avatar tonsky commented on May 22, 2024 1

Great! Do you want to work on that? I’d be happy to review a PR

from skija.

tonsky avatar tonsky commented on May 22, 2024

Good question—have you tried it? What didn’t work?

from skija.

tonsky avatar tonsky commented on May 22, 2024

This is what we depend on https://docs.oracle.com/javase/9/docs/api/java/lang/ref/Cleaner.html, avaliable since 9. So I guess the minimal version is 9

from skija.

Jojal avatar Jojal commented on May 22, 2024

Yeah i tried. I just modified the pom.xml to change the compiler version from 11 to 8, and i had an error about what you said.
java.lang.ref.Cleaner not found.

Thank you for the answer. Now i think there is no chance that this could be work with java 8.

from skija.

yuhailong626 avatar yuhailong626 commented on May 22, 2024

I tried to replace java.lang.ref.Cleaner with sun.misc.Cleaner and it worked.
Like this:
`import sun.misc.Cleaner;
public abstract class Managed extends Native implements AutoCloseable {
public Cleaner _cleaner;
public Managed(long ptr, long finalizer) {
this(ptr, finalizer, true);
}
public Managed(long ptr, long finalizer, boolean managed) {
super(ptr);
if (managed) {
assert ptr != 0L : "Managed ptr is 0";

        assert finalizer != 0L : "Managed finalizer is 0";

        String className = this.getClass().getSimpleName();
        Stats.onAllocated(className);
        this._cleaner = Cleaner.create(this, new Managed.CleanerThunk(className, ptr, finalizer));
    }

}
public void close() {
    if (0L == this._ptr) {
        throw new RuntimeException("Object already closed: " + this);
    } else if (null == this._cleaner) {
        throw new RuntimeException("Object is not managed in JVM, can't close(): " + this);
    } else {
        this._cleaner.clean();
        this._cleaner = null;
        this._ptr = 0L;
    }
}

public static native void _nInvokeFinalizer(long var0, long var2);

public static class CleanerThunk implements Runnable {
    public String _className;
    public long _ptr;
    public long _finalizerPtr;

    public CleanerThunk(String className, long ptr, long finalizer) {
        this._className = className;
        this._ptr = ptr;
        this._finalizerPtr = finalizer;
    }
    public void run() {
        Stats.onDeallocated(this._className);
        Stats.onNativeCall();
        Managed._nInvokeFinalizer(this._finalizerPtr, this._ptr);
    }
}

}`

from skija.

tonsky avatar tonsky commented on May 22, 2024

Great!

from skija.

Jojal avatar Jojal commented on May 22, 2024

Yeah it's really good ! I'm gonna try that 👍
The only thing is we need to make this patch every time there is a new version ? Or could that be handled by the skija team maybe ?

Thanks again !

from skija.

tonsky avatar tonsky commented on May 22, 2024

I don’t know a way to make two different classes for two different JVM versions.

Out of curiosity, what are the reasons that make you stay on Java 8?

from skija.

magneticflux- avatar magneticflux- commented on May 22, 2024

I don’t know a way to make two different classes for two different JVM versions.

@tonsky Coincidentally, Java 9 introduced exactly that feature! 😄
You can create multi-release jars that include classes specifically for backwards compatibility. If Cleaner is the only API needed, I think it would be pretty easy to expose the sun.misc API as the modern one on Java 8 and not break anything on newer versions.

There's a great guide for Maven use here: https://www.baeldung.com/maven-multi-release-jars

from skija.

Sm0keySa1m0n avatar Sm0keySa1m0n commented on May 22, 2024

Any status on this?

from skija.

luojinrong avatar luojinrong commented on May 22, 2024

Yeah it's really good ! I'm gonna try that 👍 The only thing is we need to make this patch every time there is a new version ? Or could that be handled by the skija team maybe ?

Thanks again !

@Jojal How do you modified the scripts to support compile? When I just replace java.lang.ref.Cleaner with sun.misc.Cleaner and run /script/build.py, it says there's no options like "--release", "--class-path" and "--module-path". After search I found these options only support in Java 9, cause I'm new in Java that do not have any idea to modify it. So if any help about how to compile it with Java 8.

Thanks in advance!

from skija.

tonsky avatar tonsky commented on May 22, 2024

@luojinrong I am curious what keeps you on Java 8? If you are new, why not start with the latest? Java 8 was released in 2014

from skija.

luojinrong avatar luojinrong commented on May 22, 2024

Cause only I'm new, uhh...but my company use java 8 on its servers. We prefer using skija with java 8 than upgrading java version on servers.

from skija.

tonsky avatar tonsky commented on May 22, 2024

How do you plan to use Skija on the servers? Just curious

from skija.

Sculas avatar Sculas commented on May 22, 2024

I'd like to use Skija with the LWJGL backend on older versions of Minecraft, which still run on Java 8 and cannot be updated due to an outdated Netty dependency.

Is there any workaround for this so I can use Skija with Java 8?

from skija.

tonsky avatar tonsky commented on May 22, 2024

@Lucaskyy just at the beginning of this thread, there’s a workaround

from skija.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.