01: /*
02: * Copyright (C) 2004, 2005 Joe Walnes.
03: * Copyright (C) 2006, 2007 XStream Committers.
04: * All rights reserved.
05: *
06: * The software in this package is published under the terms of the BSD
07: * style license a copy of which has been included with this distribution in
08: * the LICENSE.txt file.
09: *
10: * Created on 23. July 2004 by Joe Walnes
11: */
12: package com.thoughtworks.xstream.core;
13:
14: import junit.framework.TestCase;
15:
16: public class JVMTest extends TestCase {
17:
18: public void testDoesNotInsantiateStaticBlocksWhenLoadingClasses() {
19: try {
20: new JVM()
21: .loadClass("com.thoughtworks.xstream.core.EvilClass");
22: } catch (ExceptionInInitializerError error) {
23: fail("Static block was called");
24: }
25: }
26: }
27:
28: class EvilClass {
29:
30: static {
31: evil();
32: }
33:
34: static void evil() {
35: throw new RuntimeException("Evil");
36: }
37: }
|