1

I've started a project using java 16 and I'm getting errors in the project all over the place:

An error has occurred. See error log for more details.
Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @6dfcffb5

It looks like the code I have from different version of java is not working in this particular version. Any idea what I need to change maybe in the pojo class. I have only 1 pojo in the application cause it is micro service.

Thanks.

user2304483
  • 945
  • 5
  • 16
  • 37
  • hmmm this might be helpful or at least worth a read -> https://stackoverflow.com/questions/41265266/how-to-solve-inaccessibleobjectexception-unable-to-make-member-accessible-m – SpaceCowboy Jul 02 '21 at 08:17
  • For now, you can probably work around the error with `--illegal-access=permit`. But whatever code that is trying to access that method should be fixed (see https://stackoverflow.com/questions/50471466/what-to-use-instead-of-defineclass-in-java10) – Slaw Jul 02 '21 at 08:39
  • I prefer to fix it cause I'm starting new project, do you know what I should change in the code, I have simple pojo – user2304483 Jul 02 '21 at 09:00
  • Are you using any libraries/frameworks? – Slaw Jul 02 '21 at 09:48
  • Of course, springboot – user2304483 Jul 02 '21 at 12:28
  • Then it is the responsibility of Spring to fix the problem. Frameworks like that often define classes at run-time and ideally would have switched from `ClassLoader#defineClass(...)` to `Lookup#defineClass(....)` by now. Are you using the latest version of Spring Boot? – Slaw Jul 02 '21 at 23:56
  • the parent in the pom file is 2.5.2 – user2304483 Jul 03 '21 at 06:51

1 Answers1

0

You can just define the JRE system library by precising the path following the next steps: Project Folder -> Properties -> Java build path -> double clicks on JRE system library and choose your installed JRE, it works for me. And sorry for my bad English