1

I got a project with lots of dependencies and somewhere in my code I'm implementing a class, like this:

public class MyApp extends org.some.BaseClass

Problem is, there are multiple jars in the dependencies providing the base class org.some.BaseClass, some of them containing specific abstract methods that I need to implement, others don't. Obviously, the compiler wants to use one of those base classes that I don't want to implement, and it fails with this:

[ERROR] MyApp is not abstract and does not override abstract method getSome() in org.some.BaseClass

Now, from here: Find where java class is loaded from I learned about the jvm opt -verbose:class which lists all the classes that are being loaded and where it loads them from. This seems to be really nice for analyzation purposes. However, I guess since the compiler is still at work at that time and the classes have not yet been loaded fully, the source of org.some.BaseClass is not printed in the output. The compiler just fails and doesn't mention any details.

So, how can I find out what class is being compiled against at compile time? Is there another jvm flag that prints the same infos as verbose:class for files with compilation errors?

Update:

Solved by adding -verbose to the javac args. Turned out the wrong class came from a shaded jar that directly included all the classes from its dependencies. The IDE was unable to tell me about this, because that jar was also part of the project as a module.

Community
  • 1
  • 1
xor_eq
  • 3,933
  • 1
  • 29
  • 33

1 Answers1

2

From the javac manual:

-verbose - Verbose output. This includes information about each class loaded and each source file compiled.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • Thanks, that hint was helpful: I'm building the project with maven, and I needed to pass the verbose parameter to javac, not the java process executing maven. – xor_eq Feb 27 '15 at 14:57
  • To pass the verbose parameter to the Maven compiler run `mvn compile -DcompilerArgs=-verbose`. – cesarsotovalero Nov 22 '20 at 21:20