0

I have added the java.management module to my build path:

Java Build Path -> Libraries -> Modulepath -> Is modular -> Edit

I'm having this issue with:

InstanceAlreadyExistsException
MBeanRegistrationException
NotCompliantMBeanException
MalformedObjectNameException

If I look at these sources, they all extend Exceptions that are in the classpath (included modules) and go all the way up to java.lang.Exception that implements Throwable. For example:

in javax.management InstanceAlreadyExistsException extends OperationsException
in javax.management OperationsException extends JMException
in javax.management JMException extends java.lang.Exception
in java.lang Exception implements Throwable

So how on Earth is InstanceAlreadyExistsException not a subclass of Throwable? https://docs.oracle.com/javase/10/docs/api/javax/management/InstanceAlreadyExistsException.html

Roberto Murphy
  • 456
  • 5
  • 15
  • *How on Earth is InstanceAlreadyExistsException not a subclass of Throwable?*.. you just didn't attempt to traverse the complete tree up. [1](https://docs.oracle.com/javase/10/docs/api/javax/management/InstanceAlreadyExistsException.html) => [2](https://docs.oracle.com/javase/10/docs/api/javax/management/OperationsException.html) => [3](https://docs.oracle.com/javase/10/docs/api/javax/management/JMException.html) => [4](https://docs.oracle.com/javase/10/docs/api/java/lang/Exception.html) ? What other than that is your actual concern? – Naman May 08 '18 at 17:19
  • I don't understand your comment, InstanceAlreadyExistsException subclasses Throwable but I'm getting an error that it can't be thrown because it doe not subclass Throwable. In Java 8 I did not get this error. Why in Java 10 is it not considered a subclass of Throwable? – Roberto Murphy May 08 '18 at 17:50
  • Well, I missed the fact, that you've pasted the error logs as the question title itself. Also to notice are you certain that the module `java.management` resolved? – Naman May 08 '18 at 18:00
  • Since you don’t have the qualified name in the error message, you should verify that the name `InstanceAlreadyExistsException` is truly resolved to the intended `javax.management.InstanceAlreadyExistsException`. In other words, check the `import` statements (other sources of errors would be type variables or inherited nested classes of the same name, but those are less likely for a name like `InstanceAlreadyExistsException`). – Holger May 09 '18 at 09:40

1 Answers1

1

I didn't quite understand what precisely you configured in the build path settings. You shouldn't have to configure anything there but simply add requires java.management; to the module-info.java.

Besides that, this sounds like a bug in eclipse, but maybe it is already fixed (e.g. https://bugs.eclipse.org/bugs/show_bug.cgi?id=533644 sounds related).

Can you try with a recent integration build from http://download.eclipse.org/eclipse/downloads/, and if the problem still exists, report a bug at https://bugs.eclipse.org (if possible with a complete self contained example that shows the problem)?

Till Brychcy
  • 2,876
  • 1
  • 18
  • 28