Proguard

29 views
Skip to first unread message

Kevin Jones

unread,
Jun 9, 2024, 7:40:36 AM6/9/24
to jooq...@googlegroups.com
Does anybody here have any experience using JOOQ with Proguard?


First I have these warnings like this:

Warning: io.r2dbc.spi.NonNullApi: can't find referenced class javax.annotation.Nonnull
Warning: io.r2dbc.spi.NonNullApi: can't find referenced class javax.annotation.meta.TypeQualifierDefault
Warning: io.r2dbc.spi.Nullable: can't find referenced class javax.annotation.Nonnull
Warning: io.r2dbc.spi.Nullable: can't find referenced class javax.annotation.meta.When
Warning: io.r2dbc.spi.Nullable: can't find referenced class javax.annotation.meta.TypeQualifierNickname

Warning: org.jooq.impl.DSL: can't find referenced class org.jetbrains.annotations.ApiStatus$Obsolete
Warning: org.jooq.impl.DSL: can't find referenced class org.jetbrains.annotations.ApiStatus$Obsolete

Warning: org.jooq.impl.JPAConverter: can't find referenced class jakarta.persistence.AttributeConverter

Warning: org.jooq.impl.Tools: can't find referenced class jakarta.persistence.Column
Warning: org.jooq.impl.Tools: can't find referenced class jakarta.persistence.Column
Warning: org.jooq.impl.Tools: can't find referenced class jakarta.persistence.Id
Warning: org.jooq.impl.Tools: can't find referenced class jakarta.persistence.Entity
Warning: org.jooq.impl.Tools: can't find referenced class jakarta.persistence.Table
Warning: org.jooq.impl.Tools: can't find referenced class jakarta.persistence.Column
Warning: org.jooq.impl.Tools: can't find referenced class jakarta.persistence.Column
Warning: org.jooq.impl.Tools: can't find referenced class jakarta.persistence.Id
Warning: org.jooq.impl.Tools: can't find referenced class jakarta.persistence.Column

Warning: org.slf4j.LoggerFactory: can't find referenced class org.slf4j.impl.StaticLoggerBinder
etc...

Some of these I'm pretty sure are safe to ignore (the slf4j ones for example), others I'm not so sure about (the jakarta.persistence warnings). 

However if I do disable the warnings then I can run them app but I get:

Exception in thread "main" java.lang.IncompatibleClassChangeError: class org.jooq.FieldOrConstraint cannot extend sealed interface org.jooq.TableElement


This is running a KMP application on the desktop (if that helps)

Any help would be greatly appreciated!

--
Kevin Jones
KnowledgeSpike

Kevin Jones

unread,
Jun 9, 2024, 8:01:29 AM6/9/24
to jOOQ User Group
So, in the proguard rules

-keep interface org.jooq.** { <methods>; }
-keep class org.jooq.** { *; }

Seems to work!

Kevin

Rob Sargent

unread,
Jun 10, 2024, 2:17:38 AM6/10/24
to jooq...@googlegroups.com


On 6/9/24 06:01, Kevin Jones wrote:

Warning: org.jooq.impl.DSL: can't find referenced class org.jetbrains.annotations.ApiStatus$Obsolete
Warning: org.jooq.impl.DSL: can't find referenced class org.jetbrains.annotations.ApiStatus$Obsolete

jOOQ depends on jetbrains?!


Lukas Eder

unread,
Jun 10, 2024, 2:27:56 AM6/10/24
to jooq...@googlegroups.com
Hi Kevin,

Thanks for your message.

The mandatory and optional dependencies are summarised in the module-info.java file here (for reasons we might never truly know, the keyword is "static", not "optional"):

You'll find the same information in the pom.xml file, probably a bit less concise:

Those dependencies that are declared optional really are.

Some of these are transitive dependencies, also likely optional in the respective API (e.g. javax.annotation). I would expect a tool like Proguard to be optional-dependency-aware? It is not a very esoteric concept in neither Maven, module-info.java, or even OSGi. It should be possible to at least configure Proguard to drop all such warnings, assuming the relevant libraries correctly handle optionality.

On Sun, Jun 9, 2024 at 1:40 PM Kevin Jones <ke...@knowledgespike.com> wrote:
Some of these I'm pretty sure are safe to ignore (the slf4j ones for example), others I'm not so sure about (the jakarta.persistence warnings). 

It has always been optional. Starting with jOOQ 3.20, the dependency will be moved into its own module, so it won't be there by default, anymore:
 
However if I do disable the warnings then I can run them app but I get:

Exception in thread "main" java.lang.IncompatibleClassChangeError: class org.jooq.FieldOrConstraint cannot extend sealed interface org.jooq.TableElement

That must be a bug in Proguard, I suspect? I don't see anything wrong with the declarations of those types. I don't know what to do about this exception, not knowing Proguard...

Working with sealed types has been an experiment since jOOQ 3.16:

It will be abandoned in jOOQ 3.20 as it didn't bring any benefits, but caused quite some compilation overheads:

Lukas Eder

unread,
Jun 10, 2024, 2:28:58 AM6/10/24
to jooq...@googlegroups.com
Rob,

Hiding behind that interrobang, there is probably an actual, specific question?

Rob Sargent

unread,
Jun 10, 2024, 4:12:26 AM6/10/24
to jooq...@googlegroups.com


On Jun 10, 2024, at 12:28 AM, Lukas Eder <lukas...@gmail.com> wrote:


--

I was/am confused by this entry in OP's stack trace.  Isn't that the IDE?



Lukas Eder

unread,
Jun 10, 2024, 4:14:24 AM6/10/24
to jooq...@googlegroups.com
On Mon, Jun 10, 2024 at 10:12 AM Rob Sargent <robjs...@gmail.com> wrote:
I was/am confused by this entry in OP's stack trace.  Isn't that the IDE?

It's a library jOOQ uses for better IDE integration, especially for Kotlin users:

The dependency is optional.

I hope this helps

Kevin Jones

unread,
Jun 10, 2024, 12:54:44 PM6/10/24
to jooq...@googlegroups.com
Thanks Lukas,

I'll check out the links,

> That must be a bug in Proguard, I suspect? I don't see anything wrong with the declarations of those types. I don't know what to do about this exception, not knowing Proguard...

I did get this working with the

-keep interface org.jooq.** { <methods>; }
-keep class org.jooq.** { *; }

proguard rules,

Kevin

--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/CAB4ELO4tvADFP%2BUFKozZEe9v7tnt8q8zrDQxy9be8feAkVaKyg%40mail.gmail.com.


--
Kevin Jones
KnowledgeSpike
Reply all
Reply to author
Forward
0 new messages