In my application I need to use unsafe casts due to reflection. However, due to spring's custom classloader this fails.

class [Ljava.lang.Object; cannot be cast to class [Lmyapp.dataholders.Account; 
([Ljava.lang.Object; is in module java.base of loader 'bootstrap'; [Lmyapp.dataholders.Account; is in unnamed module of loader org.springframework.boot.loader.LaunchedURLClassLoader @5419f379)

Comment From: wilkinsona

This looks like a problem with Java's module system rather than Spring Boot's ClassLoader. It's hard to say what the cause may be with so little to go on, but perhaps your Account type isn't exported from the module.

If you would like us to spend some time investigating, please take the time to provide a small sample project that reproduces the problem.

Comment From: Martmists-GH

The main issue is that Account is being loaded by the spring classloader; It's not possible to cast an object from Classloader A to Classloader B similar to how you can't cast a String to an Int.

Comment From: wilkinsona

I understand the rules of casting types loaded by two different class loaders, what I don't understand is how your application is getting into that situation. As I said above, if you would like us to spend some time investigating, please take the time to provide a small sample project that reproduces the problem.

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.