📄 eclassloader.java
字号:
if (classEGraphicsOutline != null) { for (EGraphics.Outline o: EGraphics.Outline.class.getEnumConstants()) { Field f = getField(classEGraphicsOutline, o.name()); if (f == null) continue; EGraphics.Outline old = EGraphicsOutlines.put(f.get(null), o); assert old == null; } } for (Poly.Type style: Poly.Type.class.getEnumConstants()) { Field f = getField(classPolyType, style.name()); if (f == null) continue; Poly.Type old = PolyTypes.put(f.get(null), style); assert old == null; } if (classDRCTemplate != null) { for (DRCTemplate.DRCMode mode: DRCTemplate.DRCMode.class.getEnumConstants()) { Field f = getField(classDRCTemplateDRCMode, mode.name()); if (f == null) continue; DRCTemplate.DRCMode old = DRCTemplateDRCModes.put(f.get(null), mode); assert old == null; } for (DRCTemplate.DRCRuleType type: DRCTemplate.DRCRuleType.class.getEnumConstants()) { Field f = getField(classDRCTemplateDRCRuleType, type.name()); if (f == null) continue; DRCTemplate.DRCRuleType old = DRCTemplateDRCRuleTypes.put(f.get(null), type); assert old == null; } } for (Layer.Function fun: Layer.Function.class.getEnumConstants()) { Field f = getField(classLayerFunction, fun.name()); if (f == null) continue; Layer.Function old = LayerFunctions.put(f.get(null), fun); assert old == null; } for (ArcProto.Function fun: ArcProto.Function.class.getEnumConstants()) { Field f = getField(classArcProtoFunction, fun.name()); if (f == null) continue; ArcProto.Function old = ArcProtoFunctions.put(f.get(null), fun); assert old == null; } for (PrimitiveNode.Function fun: PrimitiveNode.Function.class.getEnumConstants()) { Field f = getField(classPrimitiveNodeFunction, fun.name()); if (f == null) continue; PrimitiveNode.Function old = PrimitiveNodeFunctions.put(f.get(null), fun); assert old == null; } } private static URL checkConnection(URL url) throws IOException { url.openStream().close(); return url; } @Override protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { if (name.startsWith("com.sun.electric.tool.sandbox.")) return getClass().getClassLoader().loadClass(name); return super.loadClass(name, resolve);// if (!name.startsWith("com.sun.electric.") || name.startsWith("com.sun.electric.tool.sandbox."))// return super.loadClass(name, resolve);// Class c = findLoadedClass(name);// if (c == null || c.getClassLoader() != this)// c = findClass(name);// if (resolve)// resolveClass(c);// return c; }// @Override// public URL getResource(String name) {// if (!name.startsWith("com/sun/electric/") || name.startsWith("com/sun/electric/tool/sandbox/"))// return super.getResource(name);// return findResource(name);// }//// @Override// public Enumeration<URL> getResources(String name) throws IOException {// if (!name.startsWith("com/sun/electric/") || name.startsWith("com/sun/electric/tool/sandbox/"))// return super.getResources(name);// return findResources(name);// } /* * Define class in this class loader from resource class loader found * in class loader's class loader. */ protected synchronized Class<?> defineClass(String name) throws ClassNotFoundException { String resourceName = name.replaceAll("\\.", "/") + ".class"; URL url = getClass().getClassLoader().getResource(resourceName); try { InputStream in = url.openStream(); int len = in.available(); byte[] ba = new byte[len]; in.read(ba); in.close(); return defineClass(name, ba, 0, len); } catch (IOException e) { throw new ClassNotFoundException(name); } } private Class<?> loadElectricClass(String ... className) { for (String s: className) { try { Class<?> c = loadClass("com.sun.electric." + s); if (c != null) return c; } catch (ClassNotFoundException e) { } } return null; } private Field getField(Class<?> c, String fieldName) { Field f = null; try { if (c != null) f = c.getField(fieldName); if (f != null) f.setAccessible(true); } catch (NoSuchFieldException e) { } return f; } private Field getDeclaredField(Class<?> c, String fieldName) { Field f = null; try { if (c != null) f = c.getDeclaredField(fieldName); if (f != null) f.setAccessible(true); } catch (NoSuchFieldException e) { } return f; } private Method getMethod(Class<?> c, String methodName, Class<?>... parameterTypes) { Method m = null; try { if (c != null) m = c.getMethod(methodName, parameterTypes); } catch (NoSuchMethodException e) { } return m; } private Method getDeclaredMethod(Class<?> c, String methodName, Class<?>... parameterTypes) { Method m = null; try { if (c != null) m = c.getDeclaredMethod(methodName, parameterTypes); if (m != null) m.setAccessible(true); } catch (NoSuchMethodException e) { } return m; } protected Constructor getDeclaredConstructor(Class<?> c, Class<?>... parameterTypes) { Constructor m = null; try { if (c != null) m = c.getDeclaredConstructor(parameterTypes); if (m != null) m.setAccessible(true); } catch (NoSuchMethodException e) { } return m; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -