How did you access INSTANCE?

On 04.11.25 12:56, Schalk Cronje wrote:
*Preamble*: /In Grolifant we compile the core code against Groovy 3.0.22 so that is compatible with any Gradle 7.3+. There was a bug in Grolifant where the OperatingSystem instance did not report the correct operating system./

In this file https://gitlab.com/ysb33rOrg/gradle/grolifant/-/blob/RELEASE_5_8_0/grolifant-core/src/main/groovy/org/ysb33r/grolifant5/internal/core/os/DefaultLinux.groovy?ref_type=tags, there is the line

     public static final OperatingSystem INSTANCE = new DefaultLinux()

The DefaultLinux class extends DefaultGenericUnix. Now when INSTANCE is accessed, it shows up as DefaultGenericUnix instead of DefaultLinux. (There are a couple of classes that has the same default behaviour).

To get this to work I had to change it to https://gitlab.com/ysb33rOrg/gradle/grolifant/-/blob/e1614b58e0956580831916c35f41b76476dcfcc0/grolifant-core/src/main/groovy/org/ysb33r/grolifant5/internal/core/os/DefaultLinux.groovy so that both DefaultGenericUnix and DefaultLinux has a common ancestor which does not have a static field called INSTANCE and that DefaultLinux no longer extended DefaultGenericUnix.

I guess this is a compiler bug? I don't want it fixedh, but it would great if someone can explain this behaviour.

--
Schalk W. Cronjé
Fediverse: @[email protected] (general), @[email protected] 
(outdoor), @[email protected] (photoblog), @[email protected] (videoblog), 
@[email protected] (open-source work).
Ello: @ysb33r


Reply via email to