1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.bcel.classfile;
19
20 import static org.junit.jupiter.api.Assertions.assertTrue;
21
22 import java.io.InputStream;
23 import java.net.URL;
24 import java.net.URLClassLoader;
25 import java.nio.file.Files;
26 import java.nio.file.Path;
27 import java.nio.file.Paths;
28
29 import org.junit.jupiter.api.Test;
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 public class InvalidMethodSigantureTestCase {
52
53 final class TestVisitor extends org.apache.bcel.classfile.EmptyVisitor {
54 @Override
55 public void visitField(final Field field) {
56 field.getType();
57 }
58 }
59 private static final String CLASS_NAME = "test$method name with () in it$1";
60
61 private static final String SRC_TEST_RESOURCES_KOTLIN = "src/test/resources/kotlin/";
62
63 @Test
64 public void testLoadClass() throws Exception {
65 final Path path = Paths.get(SRC_TEST_RESOURCES_KOTLIN);
66 assertTrue(Files.exists(path));
67 assertTrue(Files.isDirectory(path));
68 try (URLClassLoader cl = URLClassLoader.newInstance(new URL[] { path.toUri().toURL() })) {
69 Class.forName(CLASS_NAME, false, cl);
70 }
71 }
72
73 @Test
74
75 public void testMethodWithParens() throws Exception {
76 try (final InputStream inputStream = Files.newInputStream(Paths.get(SRC_TEST_RESOURCES_KOTLIN, CLASS_NAME + ".class"))) {
77 final ClassParser classParser = new ClassParser(inputStream, CLASS_NAME);
78 final JavaClass javaClass = classParser.parse();
79 final TestVisitor visitor = new TestVisitor();
80 new DescendingVisitor(javaClass, visitor).visit();
81 }
82 }
83 }