New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Java 9 Jigsaw support implementing module-info.java file #1979
Comments
Don't see why not. Seems innocuous enough |
I started to work on this feature today, @davecramer, seems doable but we would have to bump the JDK requirement to build the project to Java 11 (Java 9 to be more precise, but I don't think a non-LTS is an good idea). Of course we could still be building How reasonable is that? |
Next release is dropping support for Java 6 and 7. |
Note that we don't need to go to Java 9+ if we instead build a multi-version jar. If we were using maven we could use the |
I'm not an expert in JPMS but the driver already defines an Automatic-Module-Name in the manifest and should work with it. I just noted that your jdeps example doesn't link to the driver. Just for the record, I have played a little with a sample project, and adding a module-info.java is not trivial, not at least if we want to do it correctly, meaning that we should refactor the code to be modularized in the recommended way. |
I didn't see that this issue is still open, I raised one here #2657 The issue is that automatic modules cannot be used with jlink. I don't think that adding a module-info requires refactoring of the code. I generated a proper module-info for this project (see issue 2657). This one just needs to be added to the code, no other changes are required. A multi-release jar would allow to still support Java 8. |
I think we could bump the minimum Java to 11 for build purposes. |
I'd want to check with the packagers to make sure they have java 11 available on debian and redhat |
Both of them have java 11 |
Any update on this issue? |
We would love a PR. |
One step short of a PR (I don't have a coding environment handy at the moment). The following
Pop it in your project and away we go. |
The above code is wrong, a service provider does not export its code. The correct module-info should look like this:
|
*> a service provider does not export its code*
Generally yes but I suspect there will be a decent amount of code out there
that uses *org.postgresql.util.PGobject*
For myself (and ebean orm) there is code that uses PGObject when using the
types - JSON, JSONB, INET
Note that PGObject is the *ONLY* class under org.postgresql that is
explicitly used (so if we didn't use PGObject for those JSON, JSONB, INET
types ... then we would not need an exports clause in module-info).
*> requires transitive java.desktop*
Really? Oh no!! java.desktop in terms of size is huge so to have it as a
required dependency is really not great imo.
*> requires transitive java.transaction.xa*
Are you sure? I suspect this should be *requires static* ... (an optional
dependency). There are a lot of apps that don't use XA. I suspect a lot of
those requires transitives are actually requires static?
Cheers, Rob.
…On Mon, 3 Apr 2023 at 10:31, rackaracka ***@***.***> wrote:
One step short of a PR (I don't have a coding environment handy at the
moment). The following module-info.java worked for me:
module org.postgresql.jdbc
{
requires java.sql;
requires java.management;
requires java.security.sasl;
provides java.sql.Driver with org.postgresql.Driver;
exports org.postgresql;
}
Pop it in your project and away we go.
The above code is wrong, a service provider does not export its code. The
correct module-info should look like this:
module org.postgresql.jdbc {
requires java.management;
requires transitive java.desktop;
requires transitive java.logging;
requires transitive java.naming;
requires transitive java.security.jgss;
requires transitive java.security.sasl;
requires transitive java.sql;
requires transitive java.transaction.xa;
requires transitive java.xml;
provides java.sql.Driver with
org.postgresql.Driver;
}
—
Reply to this email directly, view it on GitHub
<#1979 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABTATOBORJGKM2I7RB4FB3W7H423ANCNFSM4UWIN32Q>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
The dependency on /**
* Moves the point to the supplied java.awt.Point refer to java.awt.Point for description of this.
*
* @param p Point to move to
* @see java.awt.Point
*/
public void setLocation(Point p) {
setLocation(p.x, p.y);
} I'm not sure the right course of action, but the options are.
@cowwoc How goes that PR? I know there is a cloud over modular java and dealing with Java 8 compatibility is a PITA, but "core" libraries like database drivers are the things that are most needed to make whole dependency trees modularizable. Today all that means is folks can use |
Sorry, I don't have time to work on a PR. I'm up to my eyeballs at work... I worked around this problem by using I am quite surprised that pgjdbc has a reference to |
I agree, module-info is going to get more important over time.
IMO I think this method should be removed at some point. The question is should it be deprecated for some period first? I suspect very little code uses that method at all - for example, PGPoint is not even used by
I agree. I think that is the right thing to do while that PGPoint.setLocation() method exists.
FYI Also just to note that Given that it won't be easy or practical to move As a side note / opinion / thought: The process of adding a module-info to a library does tend to highlight all the historic ugly little things in an API like dependencies we don't really want (e.g. java.desktop), dependencies we want to be optional (e.g. |
We can deprecate that.
Hmmm... nobody should be using internal functions. That said PostGIS is a pretty important part of Postgres. I'm loathe to play favourites like that though. It will be interesting to see who else depends on what internally if and when we do this . |
I use PGObject so much in my clojure code I'm shocked it would even be considered internal only. |
My comment from 2020:
One of the points of using modules is to hide the internals of some packages (better encapsulation), right now for better or for worse (and I don't think it's for better), there is no clear definition of what is internal and what is not, and this leaves us in a complicated scenario where to properly modularize the driver might require to refactor some parts of it. Ideally, to correctly modularize the driver, we should split functionality into different modules, one module could be for the core JDBC classes, one (or more) module for extensions of the driver (replication, copymanager, geometric data types, etc), and extra care should be taken to not depend on more modules that strictly necessarily, depending on There was a discussion started a couple of years ago about this: #2059 and I still maintain that properly modularizing the driver is a bigger effort than just putting a module-info. The ugly easiest path is to simply export everything and require everything that is currently used. |
Can you share how you use it ? |
(doto (PGobject.)
(.setType "jsonb")
(.setValue (json/generate-string txn-data))) Mostly stuff like this |
This is a very specific definition of "proper". This module cannot be split into sub-modules without breaking user experience. I'm willing to bet that someone, somewhere, has a curriculum for students or a production setup that relies on physically downloading the published jar and putting it on the classpath. A "properly modularized" postgres driver by your considerations would require multiple jars.
I think this is the right path. There are two parties to a modularization
As it is, if you have any non-modularized dependency the whole "module" toolchain (jlink -> j*) just doesn't work (afaik). So while hypothetically a downstream consumer might benefit from splitting up the driver into multiple modules (and that overlaps with what would be nice from a maintenance perspective) the more pressing issue is that incompatibility. |
Yes, I think splitting the code up into multiple JARs would provide the best cost/benefit over the long-term. That said, nothing prevents you from offering an all-in-one non-modular JAR alongside that if you so wish. It is likely that the major version number would increase, to signal a backward-incompatible change. So the theoretical professor wouldn't get caught off guard. That said, we have yet to establish how many people would be negatively affected by this change. Arguing in the abstract tends to end badly :)
|
I'm submitting a ...
Describe the issue
I'm trying to convert a app to be packaged using
jlink
/jdeps
, and PostgreSQL is my only dependency that does not provide module information. That is the error due to the fact that PostreSQL is an automodule:Would you consider implementing support for that? I can propose a PR for that in case you do.
Driver Version?
any
Java Version?
11
OS Version?
any
PostgreSQL Version?
any
The text was updated successfully, but these errors were encountered: