Skip to content
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

Consider renaming / aliasing org.jooq.Record #9988

Closed
lukaseder opened this issue Mar 25, 2020 · 2 comments
Closed

Consider renaming / aliasing org.jooq.Record #9988

lukaseder opened this issue Mar 25, 2020 · 2 comments

Comments

@lukaseder
Copy link
Member

Starting with more recent JDKs, we'll be in an unfortunate situation where one of our main types org.jooq.Record will be in conflict with a new type from the java.lang package: java.lang.Record. The types in java.lang are auto-imported in Java, which leads to even more confusion.

So far, we haven't had this situation. Maybe, it is not a problem - this issue is to collect feedback from the community to assess whether we need to take action. There are several options:

  • Rename the type (and subtypes) incompatibly. We could call it Rec (and Rec1, Rec2, UpdatableRec, etc.). This is thorough, but not very desireable.
  • Add a super type Rec with Record <: Rec that users could reference instead. All the Record API would go to Rec. All the receiving ends of the jOOQ API would use Rec instead of Record (e.g. Result<R extends Rec>). Methods would continue to return the more specific Record. This would be mostly source compatible (probably, some occasional invariance would get in the way), but a bit confusing.
  • Add a sub type Rec with Rec <: Record that users could reference instead. All the Record API would remain in Record. All the receiving ends of jOOQ API would continue using Record. Methods would now return Rec instead. This would be mostly source compatible (probably, some occasional invariance would get in the way), and perhaps a bit less confusing.

Perhaps, other options exist.

@lihonosov
Copy link

lihonosov commented Mar 26, 2020

yeah, my build failed with java 14 :(

Error:(150,19) java: reference to Record is ambiguous

Reference to 'Record' is ambiguous, both 'org.jooq.Record' and 'java.lang.Record' match

Everything works with explicit import:

import org.jooq.Record;

vkuzel added a commit to vkuzel/Quantum-Leap-Gradle-Plugin that referenced this issue Sep 27, 2020
…mped up to Java 11.

* Minimum allowed Gradle version is 6.3.
* The Quantum Leap project won't compile on Java 14 and newer, until jOOQ problem with conflicting class names is resolved: jOOQ/jOOQ#9988
vkuzel added a commit to vkuzel/Quantum-Leap-Gradle-Plugin that referenced this issue Nov 28, 2021
… import of conflicting classes (java.lang.Record vs org.jooq.Record) class, without optimizing it out if an import-on-demand ("wildcard import") from the same package is applied.

    See the details:
    * jOOQ/jOOQ#9988
    * https://youtrack.jetbrains.com/issue/IDEA-251602
@lukaseder lukaseder added this to To do in 3.17 Other improvements via automation May 24, 2022
@lukaseder
Copy link
Member Author

Such is life.

Very rarely, the JDK adds stuff to the java.lang package, which can break user code when users use * imports. Typically, this isn't the case as IDEs tend to expand these imports, and they keep learning about such changes, including this one. I think this is now no longer a problem in IntelliJ? Also, as var becomes more popular, it might become less of a problem as users will assign their records to a var local variable rather than declaring it explicitly.

Renaming such an ubiquitous type is almost impossible in jOOQ. It would break every piece of jOOQ code out there. This problem here can be solved quickly after upgrading to Java 14+ by using an IDE to re-organise imports.

If Java had type aliases, then a solution would be possible. But unfortunately, it doesn't.

3.17 Other improvements automation moved this from To do to Done May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

2 participants