Skip to content

Conversation

@alex-cova
Copy link

Pull Request Etiquette

Changes

  • [ x] Internal code
  • Library interface (affecting end-user code)
  • Documentation
  • Other: _____

Description

Removes the usage of Reflection in the constructor of AbstractCacheView (T[]) Array.newInstance(type, 0), This usage of reflection blocks the availability of compiling JDA into native code using Graalvm

@freya022
Copy link
Contributor

freya022 commented Sep 14, 2025

There is a lot of unwanted formatting changes, please revert those, focus the PR on the actual change.

I will also note that using reflection does NOT prevent from compiling with Native Image, it has been a supported feature for years via the tracing agent.

@freya022
Copy link
Contributor

Your changes also does not help toward your goal of reducing reflection calls, because emptyArray is passed to the TLongObjectMap#values(T[]) method, which itself also uses Array.newInstance when the array is not large enough.

In AbstractCacheView
image

In TLongObjectHashMap
image

I would strongly recommend you to use the tracing agent mentioned earlier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants