Skip to content

Commit

Permalink
Added detection of custom class loaders that reload classes from JMoc…
Browse files Browse the repository at this point in the history
…kit Coverage, throwing error with user guidance.
  • Loading branch information
rliesenfeld committed Jul 17, 2015
1 parent 45942ee commit cd41e70
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion coverage/src/mockit/coverage/data/CoverageData.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,20 @@
public final class CoverageData implements Serializable
{
private static final long serialVersionUID = -4860004226098360259L;
@Nonnull private static final CoverageData instance = new CoverageData();
@Nonnull private static final CoverageData instance;

static
{
ClassLoader classLoader = CoverageData.class.getClassLoader();

if (classLoader != ClassLoader.getSystemClassLoader()) {
throw new IllegalAccessError(
"JMockit Coverage got reloaded through custom class loader " +
classLoader.getClass().getName() + ";\r\nplease configure it to ignore classes from JMockit.");
}

instance = new CoverageData();
}

@Nonnull public static CoverageData instance() { return instance; }

Expand Down

0 comments on commit cd41e70

Please sign in to comment.