Lines 53-58
Link Here
|
53 |
return buildUniqueComplianceTestSuite(testClass(), ClassFileConstants.JDK1_5); |
53 |
return buildUniqueComplianceTestSuite(testClass(), ClassFileConstants.JDK1_5); |
54 |
} |
54 |
} |
55 |
|
55 |
|
|
|
56 |
protected void tearDown() throws Exception { |
57 |
disposeCascadedJars(); |
58 |
super.tearDown(); |
59 |
} |
60 |
|
61 |
// PREMATURE find a way to build the jars once for the whole suite |
62 |
private boolean cascadedJarsCreated; |
63 |
private String cascadedJarsDirectoryPath; |
64 |
private void createCascadedJars() { |
65 |
if (!this.cascadedJarsCreated) { |
66 |
this.cascadedJarsDirectoryPath = ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString(); |
67 |
if (!this.cascadedJarsDirectoryPath.endsWith(File.separator)) { |
68 |
this.cascadedJarsDirectoryPath = this.cascadedJarsDirectoryPath + File.separator; |
69 |
} |
70 |
try { |
71 |
Util.createJar( |
72 |
new String[] { |
73 |
"p/A.java", |
74 |
"package p;\n" + |
75 |
"public class A {\n" + |
76 |
"}", |
77 |
}, |
78 |
new String[] { |
79 |
"META-INF/MANIFEST.MF", |
80 |
"Manifest-Version: 1.0\n" + |
81 |
"Created-By: Eclipse JDT Test Harness\n" + |
82 |
"Class-Path: lib2.jar\n", |
83 |
}, |
84 |
this.cascadedJarsDirectoryPath + "lib1.jar", |
85 |
JavaCore.VERSION_1_4); |
86 |
Util.createJar( |
87 |
new String[] { |
88 |
"p/B.java", |
89 |
"package p;\n" + |
90 |
"public class B {\n" + |
91 |
"}", |
92 |
"p/R.java", |
93 |
"package p;\n" + |
94 |
"public class R {\n" + |
95 |
" public static final int R2 = 2;\n" + |
96 |
"}", |
97 |
}, |
98 |
this.cascadedJarsDirectoryPath + "lib2.jar", |
99 |
JavaCore.VERSION_1_4); |
100 |
Util.createJar( |
101 |
new String[] { |
102 |
"p/C.java", |
103 |
"package p;\n" + |
104 |
"public class C {\n" + |
105 |
"}", |
106 |
"p/R.java", |
107 |
"package p;\n" + |
108 |
"public class R {\n" + |
109 |
" public static final int R3 = 3;\n" + |
110 |
"}", |
111 |
}, |
112 |
new String[] { |
113 |
"META-INF/MANIFEST.MF", |
114 |
"Manifest-Version: 1.0\n" + |
115 |
"Created-By: Eclipse JDT Test Harness\n" + |
116 |
"Class-Path: lib4.jar\n", |
117 |
}, |
118 |
this.cascadedJarsDirectoryPath + "lib3.jar", |
119 |
JavaCore.VERSION_1_4); |
120 |
Util.createJar( |
121 |
new String[] { |
122 |
"p/D.java", |
123 |
"package p;\n" + |
124 |
"public class D {\n" + |
125 |
"}", |
126 |
}, |
127 |
new String[] { |
128 |
"META-INF/MANIFEST.MF", |
129 |
"Manifest-Version: 1.0\n" + |
130 |
"Created-By: Eclipse JDT Test Harness\n" + |
131 |
"Class-Path: lib1.jar lib3.jar\n", |
132 |
}, |
133 |
this.cascadedJarsDirectoryPath + "lib4.jar", |
134 |
JavaCore.VERSION_1_4); |
135 |
this.cascadedJarsCreated = true; |
136 |
} catch (IOException e) { |
137 |
// ignore |
138 |
} |
139 |
} |
140 |
} |
141 |
private void disposeCascadedJars() { |
142 |
if (this.cascadedJarsCreated) { |
143 |
Util.delete(this.cascadedJarsDirectoryPath + "lib1.jar"); |
144 |
Util.delete(this.cascadedJarsDirectoryPath + "lib2.jar"); |
145 |
Util.delete(this.cascadedJarsDirectoryPath + "lib3.jar"); |
146 |
Util.delete(this.cascadedJarsDirectoryPath + "lib4.jar"); |
147 |
this.cascadedJarsCreated = false; |
148 |
} |
149 |
} |
150 |
|
56 |
private String getLibraryClassesAsQuotedString() { |
151 |
private String getLibraryClassesAsQuotedString() { |
57 |
String[] paths = Util.getJavaClassLibs(); |
152 |
String[] paths = Util.getJavaClassLibs(); |
58 |
StringBuffer buffer = new StringBuffer(); |
153 |
StringBuffer buffer = new StringBuffer(); |
Lines 7815-7820
Link Here
|
7815 |
"1 problem (1 warning)", |
7910 |
"1 problem (1 warning)", |
7816 |
true); |
7911 |
true); |
7817 |
} |
7912 |
} |
|
|
7913 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
7914 |
// basic link: a jar only referenced in the manifest of the first one is found |
7915 |
public void test214_jar_ref_in_jar(){ |
7916 |
createCascadedJars(); |
7917 |
this.runConformTest( |
7918 |
new String[] { |
7919 |
"src/p/X.java", |
7920 |
"package p;\n" + |
7921 |
"/** */\n" + |
7922 |
"public class X {\n" + |
7923 |
" A a;\n" + |
7924 |
" B b;\n" + |
7925 |
"}", |
7926 |
}, |
7927 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
7928 |
+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar\"" |
7929 |
+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib2.jar\"" // WORK SIMULATED SO FAR |
7930 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
7931 |
+ " -1.5 -g -preserveAllLocals" |
7932 |
+ " -proceedOnError -referenceInfo" |
7933 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
7934 |
"", |
7935 |
"", |
7936 |
true); |
7937 |
} |
7938 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
7939 |
// basic link inactive before 1.5 |
7940 |
// WORK - reconsider |
7941 |
// may want to reconsider in favor of an |
7942 |
// explicit option (that is, do not condition links by a source level) |
7943 |
public void test215_jar_ref_in_jar(){ |
7944 |
createCascadedJars(); |
7945 |
this.runNegativeTest( |
7946 |
new String[] { |
7947 |
"src/p/X.java", |
7948 |
"package p;\n" + |
7949 |
"/** */\n" + |
7950 |
"public class X {\n" + |
7951 |
" A a;\n" + |
7952 |
" B b;\n" + |
7953 |
"}", |
7954 |
}, |
7955 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
7956 |
+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar\"" |
7957 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
7958 |
+ " -1.4 -g -preserveAllLocals" |
7959 |
+ " -proceedOnError -referenceInfo" |
7960 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
7961 |
"", |
7962 |
"----------\n" + |
7963 |
"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + |
7964 |
" B b;\n" + |
7965 |
" ^\n" + |
7966 |
"B cannot be resolved to a type\n" + |
7967 |
"----------\n" + |
7968 |
"1 problem (1 error)", |
7969 |
true); |
7970 |
} |
7971 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
7972 |
// bootclasspath does not get expanded |
7973 |
// WORK needs specific jars that replace the runtime |
7974 |
public void _test216_jar_ref_in_jar(){ |
7975 |
createCascadedJars(); |
7976 |
this.runNegativeTest( |
7977 |
new String[] { |
7978 |
"src/p/X.java", |
7979 |
"package p;\n" + |
7980 |
"/** */\n" + |
7981 |
"public class X {\n" + |
7982 |
" A a;\n" + |
7983 |
" C c;\n" + |
7984 |
"}", |
7985 |
}, |
7986 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
7987 |
+ " -bootclasspath " + getLibraryClassesAsQuotedString() |
7988 |
+ File.pathSeparator + "\"" + OUTPUT_DIR + File.separator + this.cascadedJarsDirectoryPath + "lib1.jar\"" |
7989 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
7990 |
+ " -1.5 -g -preserveAllLocals" |
7991 |
+ " -proceedOnError -referenceInfo" |
7992 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
7993 |
"", |
7994 |
"----------\n" + |
7995 |
"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + |
7996 |
" C c;\n" + |
7997 |
" ^\n" + |
7998 |
"C cannot be resolved to a type\n" + |
7999 |
"----------\n" + |
8000 |
"1 problem (1 error)", |
8001 |
true); |
8002 |
} |
8003 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8004 |
// links are followed recursively, eliminating dupes |
8005 |
public void test217_jar_ref_in_jar(){ |
8006 |
createCascadedJars(); |
8007 |
this.runConformTest( |
8008 |
new String[] { |
8009 |
"src/p/X.java", |
8010 |
"package p;\n" + |
8011 |
"/** */\n" + |
8012 |
"public class X {\n" + |
8013 |
" A a;\n" + |
8014 |
" B b;\n" + |
8015 |
" C c;\n" + |
8016 |
" D d;\n" + |
8017 |
"}", |
8018 |
}, |
8019 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8020 |
+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib3.jar\"" |
8021 |
+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib4.jar\"" // WORK SIMULATED SO FAR |
8022 |
+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar\"" // WORK SIMULATED SO FAR |
8023 |
+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib2.jar\"" // WORK SIMULATED SO FAR |
8024 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
8025 |
+ " -1.5 -g -preserveAllLocals" |
8026 |
+ " -proceedOnError -referenceInfo" |
8027 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8028 |
"", |
8029 |
"", |
8030 |
true); |
8031 |
} |
8032 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8033 |
// at first level, this is depth first, masking tailing libs |
8034 |
public void test218_jar_ref_in_jar(){ |
8035 |
createCascadedJars(); |
8036 |
this.runNegativeTest( |
8037 |
new String[] { |
8038 |
"src/p/X.java", |
8039 |
"package p;\n" + |
8040 |
"/** */\n" + |
8041 |
"public class X {\n" + |
8042 |
" int i = R.R2;\n" + |
8043 |
" int j = R.R3;\n" + |
8044 |
"}", |
8045 |
}, |
8046 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8047 |
+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar\"" |
8048 |
+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib2.jar\"" // WORK SIMULATED SO FAR |
8049 |
+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib3.jar\"" |
8050 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
8051 |
+ " -1.5 -g -preserveAllLocals" |
8052 |
+ " -proceedOnError -referenceInfo" |
8053 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8054 |
"", |
8055 |
"----------\n" + |
8056 |
"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + |
8057 |
" int j = R.R3;\n" + |
8058 |
" ^^^^\n" + |
8059 |
"R.R3 cannot be resolved\n" + |
8060 |
"----------\n" + |
8061 |
"1 problem (1 error)", |
8062 |
true); |
8063 |
} |
8064 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8065 |
// checking whether it is depth first or width first using only links |
8066 |
// depth first hypothesis |
8067 |
public void testONLY_219_jar_ref_in_jar(){ |
8068 |
createCascadedJars(); |
8069 |
this.runNegativeTest( |
8070 |
new String[] { |
8071 |
"src/p/X.java", |
8072 |
"package p;\n" + |
8073 |
"/** */\n" + |
8074 |
"public class X {\n" + |
8075 |
" int i = R.R2;\n" + |
8076 |
" int j = R.R3;\n" + |
8077 |
"}", |
8078 |
}, |
8079 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8080 |
+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib4.jar\"" |
8081 |
+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar\"" // WORK SIMULATED SO FAR |
8082 |
+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib2.jar\"" // WORK SIMULATED SO FAR |
8083 |
+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib3.jar\"" // WORK SIMULATED SO FAR |
8084 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
8085 |
+ " -1.5 -g -preserveAllLocals" |
8086 |
+ " -proceedOnError -referenceInfo" |
8087 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8088 |
"", |
8089 |
"----------\n" + |
8090 |
"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + |
8091 |
" int j = R.R3;\n" + |
8092 |
" ^^^^\n" + |
8093 |
"R.R3 cannot be resolved\n" + |
8094 |
"----------\n" + |
8095 |
"1 problem (1 error)", |
8096 |
true); |
8097 |
} |
8098 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8099 |
//tests we want: |
8100 |
//- jars are added just after the containing jar; masks following jars |
8101 |
// variations on paths (the path must be relative, use subdirectory, and .. syntax) |
8102 |
// multiple entries on a single line in the manifest |
8103 |
// repeated classpath lines in the manifest |
8104 |
// more white space than needed |
8105 |
// minimum white space |
8106 |
//- extensions are not expanded (need more work for bootclasspath and this one) |
8107 |
|
7818 |
public static Class testClass() { |
8108 |
public static Class testClass() { |
7819 |
return BatchCompilerTest.class; |
8109 |
return BatchCompilerTest.class; |
7820 |
} |
8110 |
} |