View | Details | Raw Unified | Return to bug 97332 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (+669 lines)
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
			Util.createJar(
136
				new String[] {
137
					"p/C.java",
138
					"package p;\n" +
139
					"public class C {\n" +
140
					"}",
141
					"p/R.java",
142
					"package p;\n" +
143
					"public class R {\n" +
144
					"  public static final int R3 = 3;\n" +
145
					"}",
146
				},
147
				new String[] {
148
					"META-INF/MANIFEST.MF",
149
					"Manifest-Version: 1.0\n" +
150
					"Created-By: Eclipse JDT Test Harness\n" +
151
					"Class-Path: s/lib6.jar\n",
152
				},
153
				this.cascadedJarsDirectoryPath + "lib5.jar",
154
				JavaCore.VERSION_1_4);
155
			new File(this.cascadedJarsDirectoryPath + "s").mkdir();
156
			Util.createJar(
157
				new String[] {
158
					"p/D.java",
159
					"package p;\n" +
160
					"public class D {\n" +
161
					"}",
162
				},
163
				new String[] {
164
					"META-INF/MANIFEST.MF",
165
					"Manifest-Version: 1.0\n" +
166
					"Created-By: Eclipse JDT Test Harness\n" +
167
					"Class-Path: ../lib7.jar\n",
168
				},
169
				this.cascadedJarsDirectoryPath + "s" + File.separator + "lib6.jar",
170
				JavaCore.VERSION_1_4);
171
			Util.createJar(
172
				new String[] {
173
					"p/A.java",
174
					"package p;\n" +
175
					"public class A {\n" +
176
					"}",
177
				},
178
				new String[] {
179
					"META-INF/MANIFEST.MF",
180
					"Manifest-Version: 1.0\n" +
181
					"Created-By: Eclipse JDT Test Harness\n" +
182
					"Class-Path: lib2.jar\n",
183
				},
184
				this.cascadedJarsDirectoryPath + "lib7.jar",
185
				JavaCore.VERSION_1_4);
186
			Util.createJar(
187
				new String[] {
188
					"p/F.java",
189
					"package p;\n" +
190
					"public class F {\n" +
191
					"}",
192
				},
193
				new String[] {
194
					"META-INF/MANIFEST.MF",
195
					"Manifest-Version: 1.0\n" +
196
					"Created-By: Eclipse JDT Test Harness\n" +
197
					"Class-Path: " + this.cascadedJarsDirectoryPath + "lib3.jar lib1.jar\n",
198
				},
199
				this.cascadedJarsDirectoryPath + "lib8.jar",
200
				JavaCore.VERSION_1_4);
201
			Util.createJar(
202
				new String[] {
203
					"p/G.java",
204
					"package p;\n" +
205
					"public class G {\n" +
206
					"}",
207
				},
208
				new String[] {
209
					"META-INF/MANIFEST.MF",
210
					"Manifest-Version: 1.0\n" +
211
					"Created-By: Eclipse JDT Test Harness\n" +
212
					"Class-Path: lib1.jar\n" +
213
					"Class-Path: lib3.jar\n",
214
				},
215
				this.cascadedJarsDirectoryPath + "lib9.jar",
216
				JavaCore.VERSION_1_4);
217
			this.cascadedJarsCreated = true;
218
		} catch (IOException e) {
219
			// ignore
220
		}
221
	}
222
}
223
private void disposeCascadedJars() {
224
	if (this.cascadedJarsCreated) {
225
		Util.delete(this.cascadedJarsDirectoryPath + "lib1.jar");
226
		Util.delete(this.cascadedJarsDirectoryPath + "lib2.jar");
227
		Util.delete(this.cascadedJarsDirectoryPath + "lib3.jar");
228
		Util.delete(this.cascadedJarsDirectoryPath + "lib4.jar");
229
		this.cascadedJarsCreated = false;
230
	}
231
}
232
56
private String getLibraryClassesAsQuotedString() {
233
private String getLibraryClassesAsQuotedString() {
57
	String[] paths = Util.getJavaClassLibs();
234
	String[] paths = Util.getJavaClassLibs();
58
	StringBuffer buffer = new StringBuffer();
235
	StringBuffer buffer = new StringBuffer();
Lines 7857-7862 Link Here
7857
		"invalid warning option: -warn:null,+unused. Must specify a warning token\n",
8034
		"invalid warning option: -warn:null,+unused. Must specify a warning token\n",
7858
		true);
8035
		true);
7859
}
8036
}
8037
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
8038
// basic link: a jar only referenced in the manifest of the first one is found
8039
public void test216_jar_ref_in_jar(){
8040
	createCascadedJars();
8041
	this.runConformTest(
8042
		new String[] {
8043
			"src/p/X.java",
8044
			"package p;\n" +
8045
			"/** */\n" +
8046
			"public class X {\n" +
8047
			"  A a;\n" +
8048
			"  B b;\n" +
8049
			"}",
8050
		},
8051
        "\"" + OUTPUT_DIR +  File.separator + "src/p/X.java\""
8052
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar\""
8053
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib2.jar\"" // WORK SIMULATED SO FAR
8054
		+ " -sourcepath \"" + OUTPUT_DIR +  File.separator + "src\""
8055
        + " -1.5 -g -preserveAllLocals"
8056
        + " -proceedOnError -referenceInfo"
8057
        + " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
8058
        "",
8059
        "",
8060
        true);
8061
}
8062
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
8063
// may want a specific option to mimick javac 1.4
8064
// caveat: javac 1.5 with -source 1.4 and -target 1.4 still uses the links
8065
public void _test216_jar_ref_in_jar_suppress(){
8066
	createCascadedJars();
8067
	this.runNegativeTest(
8068
		new String[] {
8069
			"src/p/X.java",
8070
			"package p;\n" +
8071
			"/** */\n" +
8072
			"public class X {\n" +
8073
			"  A a;\n" +
8074
			"  B b;\n" +
8075
			"}",
8076
		},
8077
     "\"" + OUTPUT_DIR +  File.separator + "src/p/X.java\""
8078
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar\""
8079
		+ " -sourcepath \"" + OUTPUT_DIR +  File.separator + "src\""
8080
     + " -ignoreJarClassPath -g -preserveAllLocals"
8081
     + " -proceedOnError -referenceInfo"
8082
     + " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
8083
     "",
8084
     "----------\n" + 
8085
     "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + 
8086
     "	B b;\n" + 
8087
     "	^\n" + 
8088
     "B cannot be resolved to a type\n" + 
8089
     "----------\n" + 
8090
     "1 problem (1 error)",
8091
     true);
8092
}
8093
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
8094
// links are followed recursively, eliminating dupes
8095
public void test217_jar_ref_in_jar(){
8096
	createCascadedJars();
8097
	this.runConformTest(
8098
		new String[] {
8099
			"src/p/X.java",
8100
			"package p;\n" +
8101
			"/** */\n" +
8102
			"public class X {\n" +
8103
			"  A a;\n" +
8104
			"  B b;\n" +
8105
			"  C c;\n" +
8106
			"  D d;\n" +
8107
			"}",
8108
		},
8109
		"\"" + OUTPUT_DIR +  File.separator + "src/p/X.java\""
8110
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib3.jar\""
8111
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib4.jar\"" // WORK SIMULATED SO FAR
8112
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar\"" // WORK SIMULATED SO FAR
8113
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib2.jar\"" // WORK SIMULATED SO FAR
8114
		+ " -sourcepath \"" + OUTPUT_DIR +  File.separator + "src\""
8115
		+ " -1.5 -g -preserveAllLocals"
8116
		+ " -proceedOnError -referenceInfo"
8117
		+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
8118
		"",
8119
		"",
8120
		true);
8121
}
8122
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
8123
// at first level, this is depth first, masking tailing libs
8124
public void test218_jar_ref_in_jar(){
8125
	createCascadedJars();
8126
	this.runNegativeTest(
8127
		new String[] {
8128
			"src/p/X.java",
8129
			"package p;\n" +
8130
			"/** */\n" +
8131
			"public class X {\n" +
8132
			"  int i = R.R2;\n" +
8133
			"  int j = R.R3;\n" +
8134
			"}",
8135
		},
8136
	  "\"" + OUTPUT_DIR +  File.separator + "src/p/X.java\""
8137
			+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar\""
8138
			+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib2.jar\"" // WORK SIMULATED SO FAR
8139
			+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib3.jar\""
8140
			+ " -sourcepath \"" + OUTPUT_DIR +  File.separator + "src\""
8141
	  + " -1.5 -g -preserveAllLocals"
8142
	  + " -proceedOnError -referenceInfo"
8143
	  + " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
8144
	  "",
8145
	  "----------\n" + 
8146
	  "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + 
8147
	  "	int j = R.R3;\n" + 
8148
	  "	        ^^^^\n" + 
8149
	  "R.R3 cannot be resolved\n" + 
8150
	  "----------\n" + 
8151
	  "1 problem (1 error)",
8152
	  true);
8153
}
8154
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
8155
// using only links, we adopt a depth first algorithm
8156
public void test219_jar_ref_in_jar(){
8157
	createCascadedJars();
8158
	this.runNegativeTest(
8159
		new String[] {
8160
			"src/p/X.java",
8161
			"package p;\n" +
8162
			"/** */\n" +
8163
			"public class X {\n" +
8164
			"  int i = R.R2;\n" +
8165
			"  int j = R.R3;\n" +
8166
			"}",
8167
		},
8168
	  "\"" + OUTPUT_DIR +  File.separator + "src/p/X.java\""
8169
			+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib4.jar\""
8170
			+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar\"" // WORK SIMULATED SO FAR
8171
			+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib2.jar\"" // WORK SIMULATED SO FAR
8172
			+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib3.jar\""  // WORK SIMULATED SO FAR
8173
			+ " -sourcepath \"" + OUTPUT_DIR +  File.separator + "src\""
8174
	  + " -1.5 -g -preserveAllLocals"
8175
	  + " -proceedOnError -referenceInfo"
8176
	  + " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
8177
	  "",
8178
	  "----------\n" + 
8179
	  "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + 
8180
	  "	int j = R.R3;\n" + 
8181
	  "	        ^^^^\n" + 
8182
	  "R.R3 cannot be resolved\n" + 
8183
	  "----------\n" + 
8184
	  "1 problem (1 error)",
8185
	  true);
8186
}
8187
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
8188
// managing subdirectories and .. properly
8189
public void test220_jar_ref_in_jar(){
8190
	createCascadedJars();
8191
	this.runConformTest(
8192
		new String[] {
8193
			"src/p/X.java",
8194
			"package p;\n" +
8195
			"/** */\n" +
8196
			"public class X {\n" +
8197
			"  A a;\n" +
8198
			"  B b;\n" +
8199
			"  C c;\n" +
8200
			"  D d;\n" +
8201
			"}",
8202
		},
8203
		"\"" + OUTPUT_DIR +  File.separator + "src/p/X.java\""
8204
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib5.jar\""
8205
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "s" + File.separator + "lib6.jar\"" // WORK SIMULATED SO FAR
8206
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib7.jar\"" // WORK SIMULATED SO FAR
8207
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib2.jar\"" // WORK SIMULATED SO FAR
8208
		+ " -sourcepath \"" + OUTPUT_DIR +  File.separator + "src\""
8209
		+ " -1.5 -g -preserveAllLocals"
8210
		+ " -proceedOnError -referenceInfo"
8211
		+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
8212
		"",
8213
		"",
8214
		true);
8215
}
8216
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
8217
// variant: the second jar on a line is found as well
8218
public void test221_jar_ref_in_jar(){
8219
	createCascadedJars();
8220
	this.runConformTest(
8221
		new String[] {
8222
			"src/p/X.java",
8223
			"package p;\n" +
8224
			"/** */\n" +
8225
			"public class X {\n" +
8226
			"  C c;\n" +
8227
			"}",
8228
		},
8229
     "\"" + OUTPUT_DIR +  File.separator + "src/p/X.java\""
8230
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib4.jar\""
8231
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib3.jar\"" // WORK SIMULATED SO FAR
8232
		+ " -sourcepath \"" + OUTPUT_DIR +  File.separator + "src\""
8233
     + " -1.5 -g -preserveAllLocals"
8234
     + " -proceedOnError -referenceInfo"
8235
     + " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
8236
     "",
8237
     "",
8238
     true);
8239
}
8240
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
8241
// we eat up absolute links silently
8242
public void test222_jar_ref_in_jar(){
8243
	createCascadedJars();
8244
	this.runConformTest(
8245
		new String[] {
8246
			"src/p/X.java",
8247
			"package p;\n" +
8248
			"/** */\n" +
8249
			"public class X {\n" +
8250
			"  F f;\n" +
8251
			"}",
8252
		},
8253
	"\"" + OUTPUT_DIR +  File.separator + "src/p/X.java\""
8254
			+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib8.jar\""
8255
			+ " -sourcepath \"" + OUTPUT_DIR +  File.separator + "src\""
8256
	+ " -1.5 -g -preserveAllLocals"
8257
	+ " -proceedOnError -referenceInfo"
8258
	+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
8259
	"",
8260
	"",
8261
	true);
8262
}
8263
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
8264
// absolute links do not mask following relative links
8265
public void test223_jar_ref_in_jar(){
8266
	createCascadedJars();
8267
	this.runConformTest(
8268
		new String[] {
8269
			"src/p/X.java",
8270
			"package p;\n" +
8271
			"/** */\n" +
8272
			"public class X {\n" +
8273
			"  A a;\n" +
8274
			"  F f;\n" +
8275
			"}",
8276
		},
8277
	"\"" + OUTPUT_DIR +  File.separator + "src/p/X.java\""
8278
			+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib8.jar\""
8279
			+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar\"" // WORK SIMULATED SO FAR
8280
			+ " -sourcepath \"" + OUTPUT_DIR +  File.separator + "src\""
8281
	+ " -1.5 -g -preserveAllLocals"
8282
	+ " -proceedOnError -referenceInfo"
8283
	+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
8284
	"",
8285
	"",
8286
	true);
8287
}
8288
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
8289
// absolute links are not followed
8290
public void test224_jar_ref_in_jar(){
8291
	createCascadedJars();
8292
	this.runNegativeTest(
8293
		new String[] {
8294
			"src/p/X.java",
8295
			"package p;\n" +
8296
			"/** */\n" +
8297
			"public class X {\n" +
8298
			"  C c;\n" +
8299
			"}",
8300
		},
8301
	"\"" + OUTPUT_DIR +  File.separator + "src/p/X.java\""
8302
			+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib8.jar\""
8303
			+ " -sourcepath \"" + OUTPUT_DIR +  File.separator + "src\""
8304
	+ " -1.5 -g -preserveAllLocals"
8305
	+ " -proceedOnError -referenceInfo"
8306
	+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
8307
	"",
8308
	"----------\n" + 
8309
	"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 4)\n" + 
8310
	"	C c;\n" + 
8311
	"	^\n" + 
8312
	"C cannot be resolved to a type\n" + 
8313
	"----------\n" + 
8314
	"1 problem (1 error)",
8315
	true);
8316
}
8317
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
8318
// we accept duplicate classpath lines in manifest and we follow the first line
8319
// WORK javac emits a warning - what do we want to do
8320
public void test225_jar_ref_in_jar(){
8321
	createCascadedJars();
8322
	this.runConformTest(
8323
		new String[] {
8324
			"src/p/X.java",
8325
			"package p;\n" +
8326
			"/** */\n" +
8327
			"public class X {\n" +
8328
			"  A a;\n" +
8329
			"  G g;\n" +
8330
			"}",
8331
		},
8332
	"\"" + OUTPUT_DIR +  File.separator + "src/p/X.java\""
8333
			+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib9.jar\""
8334
			+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar\"" // WORK SIMULATED SO FAR
8335
			+ " -sourcepath \"" + OUTPUT_DIR +  File.separator + "src\""
8336
	+ " -1.5 -g -preserveAllLocals"
8337
	+ " -proceedOnError -referenceInfo"
8338
	+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
8339
	"",
8340
	"",
8341
	true);
8342
}
8343
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
8344
// we accept duplicate classpath lines in manifest and we follow the jars of the
8345
// second and following lines as well
8346
// WORK javac emits a warning - what do we want to do
8347
public void test226_jar_ref_in_jar(){
8348
	createCascadedJars();
8349
	this.runConformTest(
8350
		new String[] {
8351
			"src/p/X.java",
8352
			"package p;\n" +
8353
			"/** */\n" +
8354
			"public class X {\n" +
8355
			"  C c;\n" +
8356
			"  G g;\n" +
8357
			"}",
8358
		},
8359
	"\"" + OUTPUT_DIR +  File.separator + "src/p/X.java\""
8360
			+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib9.jar\""
8361
			+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib3.jar\"" // WORK SIMULATED SO FAR
8362
			+ " -sourcepath \"" + OUTPUT_DIR +  File.separator + "src\""
8363
	+ " -1.5 -g -preserveAllLocals"
8364
	+ " -proceedOnError -referenceInfo"
8365
	+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
8366
	"",
8367
	"",
8368
	true);
8369
}
8370
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
8371
// bootclasspath does not get expanded
8372
// WORK would need taylored jars that can replace the runtime
8373
//      if we manage to do this one, we should also track extensions
8374
public void _test227_jar_ref_in_jar(){
8375
	createCascadedJars();
8376
	this.runNegativeTest(
8377
		new String[] {
8378
			"src/p/X.java",
8379
			"package p;\n" +
8380
			"/** */\n" +
8381
			"public class X {\n" +
8382
			"  A a;\n" +
8383
			"  C c;\n" +
8384
			"}",
8385
		},
8386
		"\"" + OUTPUT_DIR +  File.separator + "src/p/X.java\""
8387
	  	+ " -bootclasspath " + getLibraryClassesAsQuotedString() 
8388
	  	+ File.pathSeparator + "\"" + OUTPUT_DIR + File.separator + this.cascadedJarsDirectoryPath + "lib1.jar\""
8389
		+ " -sourcepath \"" + OUTPUT_DIR +  File.separator + "src\""
8390
		+ " -1.5 -g -preserveAllLocals"
8391
		+ " -proceedOnError -referenceInfo"
8392
		+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
8393
		"",
8394
		"----------\n" + 
8395
		"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + 
8396
		"	C c;\n" + 
8397
		"	^\n" + 
8398
		"C cannot be resolved to a type\n" + 
8399
		"----------\n" + 
8400
		"1 problem (1 error)",
8401
		true);
8402
}
8403
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
8404
// jar files reached indirectly bear the access rules of the entry that 
8405
// references them
8406
public void test228_jar_ref_in_jar(){
8407
	createCascadedJars();
8408
	this.runConformTest(
8409
		new String[] {
8410
			"src/p/X.java",
8411
			"package p;\n" +
8412
			"/** */\n" +
8413
			"public class X {\n" +
8414
			"  A a;\n" +
8415
			"}",
8416
		},
8417
		"\"" + OUTPUT_DIR +  File.separator + "src/p/X.java\""
8418
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib3.jar[~p/A]\""
8419
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib4.jar[~p/A]\"" // WORK SIMULATED SO FAR
8420
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar[~p/A]\"" // WORK SIMULATED SO FAR
8421
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib2.jar[~p/A]\"" // WORK SIMULATED SO FAR
8422
		+ " -sourcepath \"" + OUTPUT_DIR +  File.separator + "src\""
8423
		+ " -1.5 -g -preserveAllLocals"
8424
		+ " -proceedOnError -referenceInfo"
8425
		+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
8426
		"",
8427
		"----------\n" + 
8428
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 4)\n" + 
8429
		"	A a;\n" + 
8430
		"	^\n" + 
8431
		"Discouraged access: The type A is not accessible due to restriction on classpath entry D:/workspaces/junit-workspace/lib1.jar\n" + 
8432
		"----------\n" + 
8433
		"1 problem (1 warning)",
8434
		true);
8435
}
8436
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
8437
// jar files reached indirectly bear the access rules of the entry that 
8438
// references them - this hides the access rules of further instances of the
8439
// same jar on the classpath
8440
public void test229_jar_ref_in_jar(){
8441
	createCascadedJars();
8442
	this.runConformTest(
8443
		new String[] {
8444
			"src/p/X.java",
8445
			"package p;\n" +
8446
			"/** */\n" +
8447
			"public class X {\n" +
8448
			"  A a;\n" +
8449
			"}",
8450
		},
8451
		"\"" + OUTPUT_DIR +  File.separator + "src/p/X.java\""
8452
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib3.jar[~p/A]\""
8453
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib4.jar[~p/A]\"" // WORK SIMULATED SO FAR
8454
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar[~p/A]\"" // WORK SIMULATED SO FAR
8455
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib2.jar[~p/A]\"" // WORK SIMULATED SO FAR
8456
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar[-p/A]\""
8457
		+ " -sourcepath \"" + OUTPUT_DIR +  File.separator + "src\""
8458
		+ " -1.5 -g -preserveAllLocals"
8459
		+ " -proceedOnError -referenceInfo"
8460
		+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
8461
		"",
8462
		"----------\n" + 
8463
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 4)\n" + 
8464
		"	A a;\n" + 
8465
		"	^\n" + 
8466
		"Discouraged access: The type A is not accessible due to restriction on classpath entry D:/workspaces/junit-workspace/lib1.jar\n" + 
8467
		"----------\n" + 
8468
		"1 problem (1 warning)",
8469
		true);
8470
}
8471
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
8472
// jar files reached indirectly bear the access rules of the entry that 
8473
// references them - this hides the access rules of further instances of the
8474
// same jar on the classpath
8475
public void test230_jar_ref_in_jar(){
8476
	createCascadedJars();
8477
	this.runConformTest(
8478
		new String[] {
8479
			"src/p/X.java",
8480
			"package p;\n" +
8481
			"/** */\n" +
8482
			"public class X {\n" +
8483
			"  A a;\n" +
8484
			"}",
8485
		},
8486
		"\"" + OUTPUT_DIR +  File.separator + "src/p/X.java\""
8487
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib3.jar[-DUMMY]\""
8488
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib4.jar[-DUMMY]\"" // WORK SIMULATED SO FAR
8489
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar[-DUMMY]\"" // WORK SIMULATED SO FAR
8490
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib2.jar[-DUMMY]\"" // WORK SIMULATED SO FAR
8491
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar[-p/A]\""
8492
		+ " -sourcepath \"" + OUTPUT_DIR +  File.separator + "src\""
8493
		+ " -1.5 -g -preserveAllLocals"
8494
		+ " -proceedOnError -referenceInfo"
8495
		+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
8496
		"",
8497
		"",
8498
		true);
8499
}
8500
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
8501
// jar files reached indirectly bear the access rules of the entry that 
8502
// references them - this hides the access rules of further instances of the
8503
// same jar on the classpath, to the point of absorbing it if none is specified
8504
public void test231_jar_ref_in_jar(){
8505
	createCascadedJars();
8506
	this.runConformTest(
8507
		new String[] {
8508
			"src/p/X.java",
8509
			"package p;\n" +
8510
			"/** */\n" +
8511
			"public class X {\n" +
8512
			"  A a;\n" +
8513
			"}",
8514
		},
8515
		"\"" + OUTPUT_DIR +  File.separator + "src/p/X.java\""
8516
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib3.jar\""
8517
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib4.jar\"" // WORK SIMULATED SO FAR
8518
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar\"" // WORK SIMULATED SO FAR
8519
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib2.jar\"" // WORK SIMULATED SO FAR
8520
		+ " -cp \"" + this.cascadedJarsDirectoryPath + "lib1.jar[-p/A]\""
8521
		+ " -sourcepath \"" + OUTPUT_DIR +  File.separator + "src\""
8522
		+ " -1.5 -g -preserveAllLocals"
8523
		+ " -proceedOnError -referenceInfo"
8524
		+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
8525
		"",
8526
		"",
8527
		true);
8528
}
7860
public static Class testClass() {
8529
public static Class testClass() {
7861
	return BatchCompilerTest.class;
8530
	return BatchCompilerTest.class;
7862
}
8531
}
(-)src/org/eclipse/jdt/core/tests/util/Util.java (-2 / +13 lines)
Lines 312-324 Link Here
312
    }
312
    }
313
}
313
}
314
public static void createJar(String[] pathsAndContents, Map options, String jarPath) throws IOException {
314
public static void createJar(String[] pathsAndContents, Map options, String jarPath) throws IOException {
315
	createJar(pathsAndContents, null, options, jarPath);
316
}
317
public static void createJar(String[] pathsAndContents, String[] extraPathsAndContents, Map options, String jarPath) throws IOException {
315
    String classesPath = getOutputDirectory() + File.separator + "classes";
318
    String classesPath = getOutputDirectory() + File.separator + "classes";
316
    File classesDir = new File(classesPath);
319
    File classesDir = new File(classesPath);
317
    flushDirectoryContent(classesDir);
320
    flushDirectoryContent(classesDir);
318
    compile(pathsAndContents, options, classesPath);
321
    compile(pathsAndContents, options, classesPath);
322
	for (int i = 0, l = extraPathsAndContents == null ? 0 : extraPathsAndContents.length; i < l; /* inc in loop */) {
323
			File  outputFile = new File(classesPath, extraPathsAndContents[i++]);
324
			outputFile.getParentFile().mkdirs();
325
	   		Util.writeToFile(extraPathsAndContents[i++], outputFile.getAbsolutePath());
326
	}
319
    zip(classesDir, jarPath);
327
    zip(classesDir, jarPath);
320
}
328
}
321
public static void createJar(String[] pathsAndContents, String jarPath, String compliance) throws IOException {
329
public static void createJar(String[] javaPathsAndContents, String jarPath, String compliance) throws IOException {
330
	createJar(javaPathsAndContents, null, jarPath, compliance);
331
}
332
public static void createJar(String[] javaPathsAndContents, String[] extraPathsAndContents, String jarPath, String compliance) throws IOException {
322
    Map options = new HashMap();
333
    Map options = new HashMap();
323
    options.put(CompilerOptions.OPTION_Compliance, compliance);
334
    options.put(CompilerOptions.OPTION_Compliance, compliance);
324
    options.put(CompilerOptions.OPTION_Source, compliance);
335
    options.put(CompilerOptions.OPTION_Source, compliance);
Lines 331-337 Link Here
331
    options.put(CompilerOptions.OPTION_ReportTypeParameterHiding, CompilerOptions.IGNORE);
342
    options.put(CompilerOptions.OPTION_ReportTypeParameterHiding, CompilerOptions.IGNORE);
332
    options.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
343
    options.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
333
    options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE);
344
    options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE);
334
    createJar(pathsAndContents, options, jarPath);
345
    createJar(javaPathsAndContents, extraPathsAndContents, options, jarPath);
335
}
346
}
336
public static void createSourceZip(String[] pathsAndContents, String zipPath) throws IOException {
347
public static void createSourceZip(String[] pathsAndContents, String zipPath) throws IOException {
337
    String sourcesPath = getOutputDirectory() + File.separator + "sources";
348
    String sourcesPath = getOutputDirectory() + File.separator + "sources";

Return to bug 97332