Java 1.8 & Drools

185 views
Skip to first unread message

Michael C. Starkie

unread,
Feb 17, 2023, 6:44:11 PM2/17/23
to Drools Usage
Hi,
What is the highest version of Drools that will run on a Java 1.8 VM?

The documentation of Drools 7 states the following:

"We currently intend to support a minimal version of Java 8 throughout the entire 7.x series."


But, looking at the manifest of kie-api-7.73.0.Final.jar downloaded with 7.73.0, it's clearly compiled with Java 11

Manifest-Version: 1.0
Automatic-Module-Name: org.kie.api
Bnd-LastModified: 1658129358593
Build-Jdk: 11.0.14.1

Also, at run time:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/kie/api/runtime/KieContainer has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

Thanks

Matteo Mortari

unread,
Feb 18, 2023, 10:43:16 AM2/18/23
to Drools Usage
Drools 7.x works just fine with Java 1.8.

As you can see GHA is setup to use Java 1.8 and that demo application using Drools 7.73.0.Final is working just fine. Screenshot attached too.

The above is a first empirical evidence your original claim is invalid.

What you pointed out in your original email is the JDK used to produce the .jar artifact, and the Jenkins used in Red Hat uses a Red-Hat supported JDK distribution.
See also reference here.

As a reminder, you can use a more recent JDK version and to compile for a previous Java version (for as long as your java source code does not use the more recent Java features).
That is the case, as we CI with Java 11 and 8, but we produce for Java 8.

But you can verify for yourself by digging more.

If you follow the steps in the readme
unzip -p kie-api-7.73.0.Final.jar org/kie/api/runtime/KieContainer.class > KieContainer.class
javap -verbose KieContainer.class

You can notice the KieContainer.class that you mentioned, is compatible with Java 1.8:
Classfile /Users/mmortari/git/tmp/demo20230218-drools-usageNBjkebQUPTM/KieContainer.class
Last modified Feb 18, 2023; size 2561 bytes
MD5 checksum 30703f76c83e07d5bbdf362cf8496ea7
Compiled from "KieContainer.java"
public interface org.kie.api.runtime.KieContainer
minor version: 0
major version: 52

And that is what counts: Java 1.8 <==> 52
you can verify for yourself in this wikipedia page: https://en.wikipedia.org/wiki/Java_class_file#General_layout

You are likely using a kie-api-7.73.0.Final.jar not from Maven Central, which might have been produced with a different target.
If that has been downloaded from somewhere else which is not Maven Central, we could investigate more; in that case, let us know.

Hope this helps to find confirmation that Drools 7.x works just fine with Java 1.8, q.e.d.

Ciao,
MM

Screenshot 2023-02-18 at 16.27.30.png

Michael C. Starkie

unread,
Feb 18, 2023, 1:13:11 PM2/18/23
to Drools Usage
The  kie-api-7.73.0.Final.jar I used was downloaded from Drools.


How do you explain the runtime execption?

Michael C. Starkie

unread,
Feb 18, 2023, 2:09:39 PM2/18/23
to Drools Usage
I must be picking up a Drools 8 version.

From the distro:

C:\tmp\org\kie\api\runtime>javap -verbose KieContainer.class
Classfile /C:/tmp/org/kie/api/runtime/KieContainer.class
  Last modified Jul 18, 2022; size 2561 bytes

  MD5 checksum 30703f76c83e07d5bbdf362cf8496ea7
  Compiled from "KieContainer.java"
public interface org.kie.api.runtime.KieContainer
  minor version: 0
  major version: 52

Thanks for the proof

Matteo Mortari

unread,
Feb 18, 2023, 2:46:00 PM2/18/23
to Drools Usage
Yes, it must be something odd going on, on your end.

Just double-checked with the below commands the download .zip from website and, of course as expected, even the distribution zip of 7.73.0.Final contains jars targeting Java 1.8.

👉 I would strongly encourage you to use Maven, so it will be easier for you not only to manage correctly the project dependencies, but also provide and share a small reproducer in case of other problems in the future.

Here is the proof even the download zip from website for Drools 7.73.0.Final targets Java 1.8 as expected:
unzip drools-distribution-7.73.0.Final.zip
cd drools-distribution-7.73.0.Final/binaries/
javap -verbose KieContainer.class

resulting in (as expected):
Classfile /Users/mmortari/git/tmp/demo20230218-drools-usageNBjkebQUPTM/drools-distribution-7.73.0.Final/binaries/KieContainer.class

  Last modified Feb 18, 2023; size 2561 bytes
  SHA-256 checksum 284081d5b6cdcd1a394275f6d19f6efdc1fbb3f30f6ce803f023e8ed91795eed

  Compiled from "KieContainer.java"
public interface org.kie.api.runtime.KieContainer
  minor version: 0
  major version: 52

Glad it helped you,
Reply all
Reply to author
Forward
Message has been deleted
0 new messages