Why classes loaded with boot classloader (bootclasspath) doesn't include annotations

281 views Asked by At

I was writing unit tests for my javaagent but faced with behavior of JVM I guess which I wasn't aware before and I curious if there is any explanation or article about it. I tried google it and search on SO but with no success.

I found that classes which are included into boot classpath doesn't have annotations with them. To demonstrate it I created a simple JUnit test

import org.junit.Test;

public class SimpleTest {
    @Test
    public void myTest() {
    }
}

It perfectly runs of course :) but if I configure eclipse project like this:enter image description here

Then it fails with java.lang.Exception: No runnable methods. I see in the debugger that code which checks annotations cannot find them.

1

There are 1 answers

0
wolfroma On

I found answer on SO to my question which is perfectly explains what is going on (I voted up there).

https://stackoverflow.com/a/23502439/2013497

JUnit library is added by Eclipse and it goes to regular classpath whenever bootloaded classes doesn't have a way to reference them.