| 1 |
/* |
| 2 |
* $Id$ |
| 3 |
* |
| 4 |
* Copyright (C) 2003-2009 JNode.org |
| 5 |
* |
| 6 |
* This library is free software; you can redistribute it and/or modify it |
| 7 |
* under the terms of the GNU Lesser General Public License as published |
| 8 |
* by the Free Software Foundation; either version 2.1 of the License, or |
| 9 |
* (at your option) any later version. |
| 10 |
* |
| 11 |
* This library is distributed in the hope that it will be useful, but |
| 12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 13 |
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
| 14 |
* License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU Lesser General Public License |
| 17 |
* along with this library; If not, write to the Free Software Foundation, Inc., |
| 18 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 |
*/ |
| 20 |
|
| 21 |
package org.jnode.vm; |
| 22 |
|
| 23 |
import java.util.HashSet; |
| 24 |
|
| 25 |
/** |
| 26 |
* @author epr |
| 27 |
*/ |
| 28 |
public class VmProcessClassLoader extends ClassLoader { |
| 29 |
|
| 30 |
/** |
| 31 |
* Set of classname strings to skip loading via a parent classloader |
| 32 |
*/ |
| 33 |
private final HashSet<String> skipClassNames; |
| 34 |
|
| 35 |
/** |
| 36 |
* Create a new instance |
| 37 |
* |
| 38 |
* @param parent |
| 39 |
*/ |
| 40 |
public VmProcessClassLoader(ClassLoader parent) { |
| 41 |
super(parent); |
| 42 |
skipClassNames = new HashSet<String>(); |
| 43 |
skipClassNames.add("java.lang.System"); |
| 44 |
skipClassNames.add("org.jnode.vm.VmProcess"); |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Create a new instance using the system classloader as parent. |
| 49 |
*/ |
| 50 |
public VmProcessClassLoader() { |
| 51 |
this(ClassLoader.getSystemClassLoader()); |
| 52 |
} |
| 53 |
|
| 54 |
public boolean skipParentLoader(String name) { |
| 55 |
name = name.replace('/', '.'); |
| 56 |
return skipClassNames.contains(name); |
| 57 |
} |
| 58 |
|
| 59 |
} |