Java's package private visibility is an underrated feature. When you omit any visibility modifier in Java, then the default (for most objects) is package private, i.e. the object is visible only to types in the same package: class YouDontSeeMe {} class YouDontSeeMeEither {} In fact, a compilation unit (the .java file) can contain multiple such … Continue reading How to Generate Package Private Code with jOOQ’s Code Generator
Tag: visibility
A Curious Java Language Feature and How it Produced a Subtle Bug
Java's visibility rules are tricky at times. Do you know what this will print? package p; import static p.A.x; class A { static String x = "A.x"; } class B { String x = "B.x"; } class C { String x = "C.x"; class D extends B { void m() { System.out.println(x); } } } … Continue reading A Curious Java Language Feature and How it Produced a Subtle Bug
The depths of Java: API leak exposed through covariance
Java can be very tricky some times, especially in API design. Let's have a look at a very interesting showcase. jOOQ strongly separates API from implementation. All API is in the org.jooq package, and public. Most implementation is in the org.jooq.impl package and package-private. Only factories and some dedicated base implementations are public. This allows … Continue reading The depths of Java: API leak exposed through covariance