File: 02buildwithcglib2.2

package info (click to toggle)
jmock2 2.5.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,296 kB
  • sloc: java: 7,436; xml: 541; sh: 122; makefile: 24; ansic: 9
file content (86 lines) | stat: -rw-r--r-- 3,635 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
Description: To build with cglib2.2
Origin: upstream, http://svn.jmock.codehaus.org/changelog/jmock/?cs=1317

--- jmock2-2.5.1+dfsg.orig/test/org/jmock/test/unit/support/SyntheticEmptyInterfaceClassLoader.java
+++ jmock2-2.5.1+dfsg/test/org/jmock/test/unit/support/SyntheticEmptyInterfaceClassLoader.java
@@ -3,9 +3,11 @@
  */
 package org.jmock.test.unit.support;
 
+import static org.jmock.test.unit.support.MethodFactory.CLASS_FORMAT_VERSION;
+
 import java.util.regex.Pattern;
 
-import net.sf.cglib.asm.ClassWriter;
+import org.objectweb.asm.ClassWriter;
 import net.sf.cglib.core.Constants;
 
 public class SyntheticEmptyInterfaceClassLoader extends ClassLoader {
@@ -30,13 +32,15 @@ public class SyntheticEmptyInterfaceClas
     }
 
     private Class<?> synthesiseInterface(String name) throws ClassFormatError {
-        ClassWriter writer = new ClassWriter(true);
-        writer.visit(MethodFactory.CLASS_FORMAT_VERSION,
-                     Constants.ACC_PUBLIC | Constants.ACC_INTERFACE,
-                     name.replace('.', '/'),
-                     "java/lang/Object",
-                     null, /* interfaces */
-                     null /* source file */);
+        ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
+                writer.visit(CLASS_FORMAT_VERSION,
+                             Constants.ACC_PUBLIC|Constants.ACC_INTERFACE,
+                             MethodFactory.nameToClassFormat(name),
+                             null,
+                             "java/lang/Object",
+                             null /* interfaces */);
+         
+
         
         byte[] b = writer.toByteArray();
 
--- jmock2-2.5.1+dfsg.orig/test/org/jmock/test/unit/support/MethodFactory.java
+++ jmock2-2.5.1+dfsg/test/org/jmock/test/unit/support/MethodFactory.java
@@ -4,13 +4,13 @@ package org.jmock.test.unit.support;
 
 import java.lang.reflect.Method;
 
-import net.sf.cglib.asm.ClassWriter;
-import net.sf.cglib.asm.Type;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.Type;
 import net.sf.cglib.core.Constants;
 
 
 public class MethodFactory extends ClassLoader {
-    public static final int CLASS_FORMAT_VERSION = 45;
+    public static final int CLASS_FORMAT_VERSION = 49;
     
     public static Class<?>[] NO_ARGUMENTS = {};
     public static Class<?>[] NO_EXCEPTIONS = {};
@@ -33,20 +33,20 @@ public class MethodFactory extends Class
         {
             @Override
             protected Class<?> findClass( String interfaceName ) {
-                ClassWriter writer = new ClassWriter(true);
+                ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
 
                 writer.visit(CLASS_FORMAT_VERSION,
                              Constants.ACC_PUBLIC|Constants.ACC_INTERFACE,
                              nameToClassFormat(interfaceName),
+                             null,
                              "java/lang/Object",
-                             null, /* interfaces */
-                             null  /* source file */);
+                             null /* interfaces */);
 
                 writer.visitMethod(Constants.ACC_PUBLIC | Constants.ACC_ABSTRACT,
                                    methodName,
                                    methodDescriptor(returnType, argTypes),
-                                   classNamesInClassFormat(exceptionTypes),
-                                   null /* no attributes */);
+                                   null,
+                                   classNamesInClassFormat(exceptionTypes));
 
                 byte[] classAsBytes = writer.toByteArray();