From: <cg...@us...> - 2009-08-23 18:45:33
|
Revision: 6711 http://jython.svn.sourceforge.net/jython/?rev=6711&view=rev Author: cgroves Date: 2009-08-23 18:45:25 +0000 (Sun, 23 Aug 2009) Log Message: ----------- Allow checked exceptions to be defined on generated methods and pass through checked exceptions for generated proxy methods Modified Paths: -------------- branches/customizable-proxymaker/src/org/python/compiler/ClassFile.java branches/customizable-proxymaker/src/org/python/compiler/ProxyCodeHelpers.java branches/customizable-proxymaker/src/org/python/compiler/ProxyMaker.java Modified: branches/customizable-proxymaker/src/org/python/compiler/ClassFile.java =================================================================== --- branches/customizable-proxymaker/src/org/python/compiler/ClassFile.java 2009-08-23 17:35:06 UTC (rev 6710) +++ branches/customizable-proxymaker/src/org/python/compiler/ClassFile.java 2009-08-23 18:45:25 UTC (rev 6711) @@ -74,7 +74,11 @@ } public Code addMethod(String name, String type, int access) { - MethodVisitor mv = cw.visitMethod(access, name, type, null, null); + return addMethod(name, type, access, null); + } + + public Code addMethod(String name, String type, int access, String[] exceptions) { + MethodVisitor mv = cw.visitMethod(access, name, type, null, exceptions); Code pmv = new Code(mv, type, access); methodVisitors.add(pmv); return pmv; Modified: branches/customizable-proxymaker/src/org/python/compiler/ProxyCodeHelpers.java =================================================================== --- branches/customizable-proxymaker/src/org/python/compiler/ProxyCodeHelpers.java 2009-08-23 17:35:06 UTC (rev 6710) +++ branches/customizable-proxymaker/src/org/python/compiler/ProxyCodeHelpers.java 2009-08-23 18:45:25 UTC (rev 6711) @@ -56,13 +56,21 @@ } } + public static String[] mapClasses(Class<?>[] classes) { + String[] mapped = new String[classes.length]; + for (int i = 0; i < mapped.length; i++) { + mapped[i] = mapClass(classes[i]); + } + return mapped; + } + public static String mapClass(Class<?> c) { String name = c.getName(); int index = name.indexOf("."); if (index == -1) { return name; } - StringBuffer buf = new StringBuffer(name.length()); + StringBuilder buf = new StringBuilder(name.length()); int last_index = 0; while (index != -1) { buf.append(name.substring(last_index, index)); Modified: branches/customizable-proxymaker/src/org/python/compiler/ProxyMaker.java =================================================================== --- branches/customizable-proxymaker/src/org/python/compiler/ProxyMaker.java 2009-08-23 17:35:06 UTC (rev 6710) +++ branches/customizable-proxymaker/src/org/python/compiler/ProxyMaker.java 2009-08-23 18:45:25 UTC (rev 6711) @@ -377,7 +377,8 @@ int access, Class<?> declaringClass) { names.add(name); - Code code = classfile.addMethod(name, makeSig(ret, parameters), access); + Code code = classfile.addMethod(name, makeSig(ret, parameters), access, + mapClasses(exceptions)); code.aload(0); code.ldc(name); if (declaringClass != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |