Skip to content

Conversation

@mbien
Copy link
Member

@mbien mbien commented Aug 2, 2025

  • gradle 9 removed some deprecated API (which broke gradle project support)
  • introspecting updateDaemonJvm.vendor.* causes OOME in daemon (uses 512MB by default, but 4GB were also not sufficient). Added 'vendor' to exclude set.
  • init with latest supported gradle version by locking the major component (instead of using 'current')

tested hello world project loading between gradle 5 and 9.

for future reference:
I found this by increasing daemon Xmx, setting MAX_INTROSPECTION_DEPTH to a low value, e.g 8, then setting a breakpoint at

and attaching the debugger to the daemon.

MAX_INTROSPECTION_DEPTH is probably far too high to protect from OOMEs but it will depend on the shape of the graph.

The annoying part was to debug a daemon while extide/gradle/netbeans-gradle-tooling is trying to start daemons too, given that it is a gradle project ;)

@mbien mbien added this to the NB27 milestone Aug 2, 2025
@mbien mbien added Gradle [ci] enable "build tools" tests ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Aug 2, 2025
@mbien mbien requested review from lkishalmi and sdedic August 3, 2025 13:23
@mbien
Copy link
Member Author

mbien commented Aug 3, 2025

would be nice if a heavy gradle user could run this against some of their projects as smoke test. (hello world worked with gradle 5-9)

@mbien mbien requested a review from neilcsmith-net August 3, 2025 17:14
@mbien
Copy link
Member Author

mbien commented Aug 3, 2025

added a second commit which works analog to #8606 but locks the major version component of the returned version. Currently set to 9. This should make it a bit safer (+ it fits that gradle 9 started to use semantic versioning). Commits meant to be squashed if we decide to do that.

@mbien mbien force-pushed the gradle9-fixes branch 2 times, most recently from aca346c to 7e1d11e Compare August 3, 2025 19:56
@sdedic
Copy link
Member

sdedic commented Aug 4, 2025

introspecting updateDaemonJvm.vendor.* causes OOME in daemon (uses 512MB by default, but 4GB were also not sufficient)

Can you file an issue for this + assign it (to me ?)

@sdedic
Copy link
Member

sdedic commented Aug 4, 2025

will likely need some tweaks for compatibility with older gradle versions

Note to self:

  • getFirstLevelModuleDependencies() did not exist before gradle 4.0 (roughly); NB code seems to support even 3.1 (?)
  • GradleVersion did not exist before 8.0 (?)

@neilcsmith-net
Copy link
Member

* `getFirstLevelModuleDependencies()` did not exist before gradle 4.0 (roughly); NB code seems to support even 3.1 (?)

NB can only support the versions that the Tooling API supports. I'm not sure if the current version supports 3.x. Think I saw once we upgrade to v9 that the lowest support would be 4.x.

* `GradleVersion` did not exist before 8.0 (?)

It's much older but for some reason not in the docs. We've been using since at least #5014 This usage appears to have been missed in that.

As discussed on Slack, longer term it would be good to see whether the Tooling API and models can now actually cover all of the introspection we need - make some of this someone else's problem!

@neilcsmith-net
Copy link
Member

added a second commit which works analog to #8606 but locks the major version component of the returned version. Currently set to 9. This should make it a bit safer (+ it fits that gradle 9 started to use semantic versioning). Commits meant to be squashed if we decide to do that.

Makes sense! The change in #8606 was intended to stabilise the existing semantics, and remove the starting of two daemons / download of two distributions problem.

Is the services.gradle.org list by major version new??? I could swear that wasn't there when I did that PR. The wrapper has been enhanced to support specifying version like that in Gradle 9 so maybe it's been added since.

Copy link
Member

@neilcsmith-net neilcsmith-net left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me with limited testing. New project working, and some old projects tested.

Added versioning API a good idea.

Thanks @mbien !

Aside : In testing old projects I'm curious why the changes in #5158 disable the Java runtime setting in certain circumstances? Seems hit and miss whether this can be changed on a broken project that needs a lower JDK.

"shouldRunAfter",
"enabled",
"description",
"vendor",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just as note: this fixes the cycle (OOME) by excluding the updateDaemonJvm.vendor.* path

this had similar symptoms as #6674 (comment) but surfaced as OOME instead of stack overflow.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me propose a different fix -- I've debugged this and (mea culpa !!!) it's caused by serializing STATIC properties reported by the metaobject. And in the JvmVendorSpec case, each instance has another set of 13 properties. Although recursive serialization of the same instance is guarded ... combinatiorial explosion is not.

 - gradle 9 removed some deprecated API
 - introspecting 'updateDaemonJvm.vendor.*' causes OOME in daemon
   added 'vendor' to exclude set
 - init with latest supported gradle version by locking the major
   component (instead of using 'current')
@mbien
Copy link
Member Author

mbien commented Aug 4, 2025

GradleVersion did not exist before 8.0 (?)

I wondered about that too, but @lkishalmi explained to me on slack that I shouldn't worry about this since the class is in fact super old. My hypothesis is that the class moved from tooling to distribution (or the other way around) at least once, thats why its missing in javadoc.

getFirstLevelModuleDependencies() did not exist before gradle 4.0 (roughly); NB code seems to support even 3.1 (?)

the oldest gradle version where hello world project loading worked seems to be 5.0 but I could have made some mistakes while backporting the project config while testing.

going to squash

@mbien mbien marked this pull request as ready for review August 4, 2025 10:59
@sdedic
Copy link
Member

sdedic commented Aug 4, 2025

The annoying part was to debug a daemon while extide/gradle/netbeans-gradle-tooling is trying to start daemons too, given that it is a gradle project ;)

FWIW, i use

tryme.args=-J-Dnetbeans.debug.gradle.info.action=true

in nbbuild/user.build.properties

The development IDE (and about everyone) happily gradles, but the debugged NetBeans creates another daemon instance. Yes, sometimes I need to kill all gradles

ps ax | grep gradle-launcher | grep -v 'grep' | sed -rn 's/ *([0-9]+).*/\1/p' | xargs kill

@mbien mbien marked this pull request as draft August 4, 2025 14:32
@mbien
Copy link
Member Author

mbien commented Aug 4, 2025

Is this PR intended to fix also org.gradle.util.VersionNumber ?

yes, this is also fixed by this PR

@MartinBalin
Copy link
Contributor

Seems like I've cloned your repo, but still has old code. Sorry. Checking it

@MartinBalin
Copy link
Contributor

After rebuilding from correct branch I can confirm project using Gradle 9 loads correctly.

@mbien
Copy link
Member Author

mbien commented Aug 4, 2025

since we have merges on hold atm and this would stabilize CI, I am going to merge this to delivery and sync back using #8698

RC 3 will be later this week so there would be still time to add more safeguards against introspection cycles if needed, without delaying other progress unnecessarily.

@mbien mbien marked this pull request as ready for review August 4, 2025 17:43
@mbien mbien merged commit 35ccdfe into apache:delivery Aug 4, 2025
33 checks passed
@mbien mbien mentioned this pull request Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) Gradle [ci] enable "build tools" tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants