seaside1 / jrule

openHAB Java Rules Engine
Eclipse Public License 2.0
29 stars 15 forks source link

Update to openhab 4.0.0 #153

Closed seaside1 closed 1 year ago

seaside1 commented 1 year ago

Update to openHAB 4.0.0

seaside1 commented 1 year ago

JRule works under openHAB 4.0.0. One problem is that it is not possible to extract the jar-files like it is done in Java 11.

09:17:33.319 [docker-java-stream-1769901458] INFO docker.openhab - STDOUT: 07:17:33.315 [ERROR] [.jrule.internal.handler.JRuleHandler] - [JRuleHandler] Compilation failed, not creating jar file 09:17:33.319 [docker-java-stream-1769901458] INFO docker.openhab - STDOUT: 07:17:33.315 [INFO ] [.jrule.internal.handler.JRuleHandler] - [JRuleHandler] Compiling rules 09:17:33.319 [docker-java-stream-1769901458] INFO docker.openhab - STDOUT: 07:17:33.316 [DEBUG] [utomation.jrule.internal.JRuleConfig] - [+JRuleConf+] Openhab Conf Property: /openhab/conf

This is what is failing under java 17

 private Vector<Class<?>> getLoadedClasses(ClassLoader classLoader) {
        Field field = null;
        try {
            field = ClassLoader.class.getDeclaredField("classes");
            field.setAccessible(true);
        } catch (Throwable t) {
            return null;
        }
        try {
            @SuppressWarnings("unchecked")
            final Vector<Class<?>> classes = (Vector<Class<?>>) field.get(classLoader);
            return classes;
        } catch (IllegalArgumentException | IllegalAccessException ignored) {
        }
        return null;
    }

Since jar file extraction is failing compiling will fail and all docker-tests will fail.

seaside1 commented 1 year ago

Seems to work now for openHAB 4.

seaside1 commented 1 year ago

Nice fixes @querdenker2k question is when we should switch main to 4.x.x

querdenker2k commented 1 year ago

for me we could switch the main branch to 4.x

seaside1 commented 1 year ago

I have created a 3.x.x branch. Please review this PR, and I'll merge it to main.