Skip to content

PreDestroy hooks fail depending on method modifiers #30636

@Saladoc

Description

@Saladoc

Describe the bug

Given classes SuperClass and ImplClass in different packages with ImplClass extends SuperClass, a @PreDestroy annotated method on the SuperClass can not be called by quarkus.

Error message reads:
Error occurred while destroying instance of bean [ImplClass_Bean]: java.lang.IllegalAccessError: ImplClass_Bean tried to access method 'void SuperClass.preDestroyHook()' (ImplClass_Bean and SuperClass are in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader

Expected behavior

The preDestroyHook() gets called successfully regardless of modifiers.

Actual behavior

The preDestroyHook() only gets called successfully if it is public.

For default and protected visibility, the behavior as described above occurs.

For private, the method gets called successfully, but arc warns about private visibility not being recommended.

How to Reproduce?

Minimal reproducer app

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

tested for each of 3.0.0.Alpha3, 2.16.0.Final, 2.13.7.Final

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

Zulip conversation

Metadata

Metadata

Assignees

Labels

area/arcIssue related to ARC (dependency injection)kind/bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions