View | Details | Raw Unified | Return to bug 146554
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (-3 / +316 lines)
Lines 865-874 Link Here
865
        "    -sourcepath <directories and zip/jar files separated by " + File.pathSeparator + ">\n" + 
865
        "    -sourcepath <directories and zip/jar files separated by " + File.pathSeparator + ">\n" + 
866
        "                       specify location for application sources. Each directory\n" + 
866
        "                       specify location for application sources. Each directory\n" + 
867
        "                       or file can specify access rules for types between ''[''\n" + 
867
        "                       or file can specify access rules for types between ''[''\n" + 
868
        "                       and '']''.\n" + 
868
        "                       and '']''. Each directory can further specify a specific\n" + 
869
        "                       destination directory using a ''-d'' option between ''[''\n" +
870
        "                       and '']''; this overrides the general ''-d'' option.\n" +
869
        "                       .class files created from source files contained in a\n" + 
871
        "                       .class files created from source files contained in a\n" + 
870
        "                       jar file are put in the user.dir folder in case no\n" + 
872
        "                       jar file are put in the user.dir folder in case no\n" + 
871
        "                       destination directory is specified.\n" + 
873
        "                       general ''-d'' option is specified. zip/jar files cannot\n" +
874
        "                       override the general ''-d'' option\n" + 
872
        "    -extdirs <directories separated by " + File.pathSeparator + ">\n" + 
875
        "    -extdirs <directories separated by " + File.pathSeparator + ">\n" + 
873
        "                       specify location for extension zip/jar files\n" + 
876
        "                       specify location for extension zip/jar files\n" + 
874
        "    -endorseddirs <directories separated by " + File.pathSeparator + ">\n" + 
877
        "    -endorseddirs <directories separated by " + File.pathSeparator + ">\n" + 
Lines 890-896 Link Here
890
        "    -1.6               use 1.6 compliance level (implicit -source 1.6\n" + 
893
        "    -1.6               use 1.6 compliance level (implicit -source 1.6\n" + 
891
        "                       -target 1.6)\n" + 
894
        "                       -target 1.6)\n" + 
892
        "    -source <version>  set source level: 1.3 to 1.6 (or 5, 5.0, 6 or 6.0)\n" + 
895
        "    -source <version>  set source level: 1.3 to 1.6 (or 5, 5.0, 6 or 6.0)\n" + 
893
        "    -target <version>  set classfile target level: 1.1 to 1.6 (or 5, 5.0, 6 or 6.0)\n" + 
896
        "    -target <version>  set classfile target level: 1.1 to 1.6 (or 5, 5.0, 6\n" +
897
        "                       or 6.0)\n" + 
894
        " \n" + 
898
        " \n" + 
895
        " Warning options:\n" + 
899
        " Warning options:\n" + 
896
        "    -deprecation     + deprecation outside deprecated code\n" + 
900
        "    -deprecation     + deprecation outside deprecated code\n" + 
Lines 3046-3051 Link Here
3046
        "ERR: invalid spec",
3050
        "ERR: invalid spec",
3047
        true);
3051
        true);
3048
}
3052
}
3053
3054
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=146554
3055
// per source directory output directory
3056
// pre-existing case 1: using a single, definite output directory
3057
public void test058_per_source_output_directory(){
3058
	String source1 = "src1",
3059
		output1 = "bin1";
3060
	this.runConformTest(
3061
		new String[] {
3062
			source1 + File.separator + "/X.java",
3063
			"public class X {}",
3064
			"Z.java",
3065
			"public class Z {\n" +
3066
			"  X f;\n" +
3067
			"}",
3068
        },
3069
        "\"" + OUTPUT_DIR +  File.separator + 
3070
        	"Z.java\""
3071
        + " -1.5"
3072
        + " -sourcepath \"" + OUTPUT_DIR + File.separator + source1 + "\""
3073
        + " -d \"" + OUTPUT_DIR + File.separator + output1 + "\"",
3074
		"", 
3075
		"",
3076
		true);
3077
	String fileName = OUTPUT_DIR + File.separator + output1 + 
3078
			File.separator + "X.class";
3079
	assertTrue("missing file: " + fileName, (new File(fileName)).exists());
3080
	fileName = OUTPUT_DIR + File.separator + output1 + 
3081
			File.separator + "Z.class";
3082
	assertTrue("missing file: " + fileName, (new File(fileName)).exists());
3083
}
3084
3085
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=146554
3086
// per source directory output directory
3087
// pre-existing case 2: using no definite output directory
3088
public void test059_per_source_output_directory(){
3089
	String source1 = "src1";
3090
	this.runConformTest(
3091
		new String[] {
3092
			source1 + File.separator + "/X.java",
3093
			"public class X {}",
3094
			"Z.java",
3095
			"public class Z {\n" +
3096
			"  X f;\n" +
3097
			"}",
3098
        },
3099
        "\"" + OUTPUT_DIR +  File.separator + 
3100
        	"Z.java\""
3101
        + " -1.5"
3102
        + " -sourcepath \"" + OUTPUT_DIR + File.separator + source1 + "\"",
3103
		"", 
3104
		"",
3105
		true);
3106
	String fileName = OUTPUT_DIR + File.separator + source1 + 
3107
			File.separator + "X.class";
3108
	assertTrue("missing file: " + fileName, (new File(fileName)).exists());
3109
	fileName = OUTPUT_DIR + File.separator + "Z.class";
3110
	assertTrue("missing file: " + fileName, (new File(fileName)).exists());
3111
}
3112
3113
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=146554
3114
// per source directory output directory
3115
// new case 1: overriding the default output directory for one of the sources
3116
public void test060_per_source_output_directory(){
3117
	String source1 = "src1",
3118
		output1 = "bin1", output2 = "bin2";
3119
	this.runConformTest(
3120
		new String[] {
3121
			source1 + File.separator + "/X.java",
3122
			"public class X {}",
3123
			"Z.java",
3124
			"public class Z {\n" +
3125
			"  X f;\n" +
3126
			"}",
3127
        },
3128
        "\"" + OUTPUT_DIR +  File.separator + 
3129
        	"Z.java\""
3130
        + " -1.5"
3131
        + " -sourcepath \"" + OUTPUT_DIR + File.separator + source1 + "\""
3132
        + "[-d \"" + OUTPUT_DIR + File.separator + output1 + "\"]"
3133
        + " -d \"" + OUTPUT_DIR + File.separator + output2 + "\"",
3134
		"", 
3135
		"",
3136
		true);
3137
	String fileName = OUTPUT_DIR + File.separator + output1 + 
3138
			File.separator + "X.class";
3139
	assertTrue("missing file: " + fileName, (new File(fileName)).exists());
3140
	fileName = OUTPUT_DIR + File.separator + source1 + 
3141
			File.separator + "X.class";
3142
	assertFalse("extraneous file: " + fileName, (new File(fileName)).exists());
3143
	fileName = OUTPUT_DIR + File.separator + output2 + 
3144
			File.separator + "X.class";
3145
	assertFalse("extraneous file: " + fileName, (new File(fileName)).exists());
3146
	fileName = OUTPUT_DIR + File.separator + output2 + 
3147
			File.separator + "Z.class";
3148
	assertTrue("missing file: " + fileName, (new File(fileName)).exists());
3149
}
3150
3151
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=146554
3152
// per source directory output directory
3153
// new case 2: specifying an output directory for a given source directory only
3154
public void test061_per_source_output_directory(){
3155
	String source1 = "src1", 
3156
		output1 = "bin1";
3157
	this.runConformTest(
3158
		new String[] {
3159
			source1 + File.separator + "/X.java",
3160
			"public class X {}",
3161
			"Z.java",
3162
			"public class Z {\n" +
3163
			"  X f;\n" +
3164
			"}",
3165
        },
3166
        "\"" + OUTPUT_DIR +  File.separator + 
3167
        	"Z.java\""
3168
        + " -1.5"
3169
        + " -sourcepath \"" + OUTPUT_DIR + File.separator + source1 + "\""
3170
        + "[-d \"" + OUTPUT_DIR + File.separator + output1 + "\"]",
3171
		"", 
3172
		"",
3173
		true);
3174
	String fileName = OUTPUT_DIR + File.separator + output1 + 
3175
			File.separator + "X.class";
3176
	assertTrue("missing file: " + fileName, (new File(fileName)).exists());
3177
	fileName = OUTPUT_DIR + File.separator + source1 + 
3178
			File.separator + "X.class";
3179
	assertFalse("extraneous file: " + fileName, (new File(fileName)).exists());
3180
	fileName = OUTPUT_DIR + File.separator + "Z.class";
3181
	assertTrue("missing file: " + fileName, (new File(fileName)).exists());
3182
}
3183
3184
// per sourcepath directory default encoding
3185
// TODO (maxime) enter suggestion
3186
public void _test062_per_sourcepath_directory_default_encoding(){
3187
	String source1 = "src1";
3188
	this.runConformTest(
3189
		new String[] {
3190
			source1 + File.separator + "/X.java",
3191
			"public class X {}",
3192
			"Z.java",
3193
			"public class Z {\n" +
3194
			"  X f;\n" +
3195
			"}",
3196
        },
3197
        "\"" + OUTPUT_DIR +  File.separator + 
3198
        	"Z.java\""
3199
        + " -1.5"
3200
        + " -sourcepath \"" + OUTPUT_DIR + File.separator + source1 
3201
        + "[UTF-8]\"",
3202
		"", 
3203
		"",
3204
		true);
3205
}
3206
3207
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=146554
3208
// per source directory output directory
3209
// [-d none] is forbidden
3210
public void test063_per_source_output_directory(){
3211
	this.runNegativeTest(
3212
		new String[] {
3213
			"X.java",
3214
			"public class X {\n" +
3215
			"  Zork z;\n" +
3216
			"}"},
3217
        "\"" + OUTPUT_DIR +  File.separator + 
3218
        	"X.java\""
3219
        + " -1.5"
3220
        + " -sourcepath \"" + OUTPUT_DIR + "\"" + "[-d none]",
3221
		"", 
3222
		"incorrect classpath: ---OUTPUT_DIR_PLACEHOLDER---[-d none]\n" + 
3223
		"----------\n" + 
3224
		"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 2)\n" + 
3225
		"	Zork z;\n" + 
3226
		"	^^^^\n" + 
3227
		"Zork cannot be resolved to a type\n" + 
3228
		"----------\n" + 
3229
		"1 problem (1 error)",
3230
		true);
3231
}
3232
3233
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=146554
3234
// per source directory output directory
3235
// [-d dir][rule] is forbidden
3236
public void test064_per_source_output_directory(){
3237
	this.runNegativeTest(
3238
		new String[] {
3239
			"X.java",
3240
			"public class X {\n" +
3241
			"  Zork z;\n" +
3242
			"}"},
3243
        "\"" + OUTPUT_DIR +  File.separator + 
3244
        	"X.java\""
3245
        + " -1.5"
3246
        + " -sourcepath \"" + OUTPUT_DIR + "\"" + "[-d dir][~**/internal/*]",
3247
		"", 
3248
		"incorrect classpath: ---OUTPUT_DIR_PLACEHOLDER---[-d dir][~**/internal/*]\n" + 
3249
		"----------\n" + 
3250
		"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 2)\n" + 
3251
		"	Zork z;\n" + 
3252
		"	^^^^\n" + 
3253
		"Zork cannot be resolved to a type\n" + 
3254
		"----------\n" + 
3255
		"1 problem (1 error)",
3256
		true);
3257
}
3258
3259
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=146554
3260
// per source directory output directory
3261
// [rule][-d dir] is ok
3262
public void test065_per_source_output_directory(){
3263
	this.runNegativeTest(
3264
		new String[] {
3265
			"X.java",
3266
			"public class X {\n" +
3267
			"  Zork z;\n" +
3268
			"}"},
3269
        "\"" + OUTPUT_DIR +  File.separator + 
3270
        	"X.java\""
3271
        + " -1.5"
3272
        + " -sourcepath \"" + OUTPUT_DIR + "\"" + "[~**/internal/*][-d dir]",
3273
		"", 
3274
		"----------\n" + 
3275
		"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 2)\n" + 
3276
		"	Zork z;\n" + 
3277
		"	^^^^\n" + 
3278
		"Zork cannot be resolved to a type\n" + 
3279
		"----------\n" + 
3280
		"1 problem (1 error)",
3281
		true);
3282
}
3283
3284
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=146554
3285
// per source directory output directory
3286
// -cp dir[-d dir] is forbidden
3287
public void test066_per_source_output_directory(){
3288
	this.runNegativeTest(
3289
		new String[] {
3290
			"X.java",
3291
			"public class X {\n" +
3292
			"  Zork z;\n" +
3293
			"}"},
3294
        "\"" + OUTPUT_DIR +  File.separator + 
3295
        	"X.java\""
3296
        + " -1.5"
3297
        + " -cp \"" + OUTPUT_DIR + "\"" + "[-d dir]",
3298
		"", 
3299
		"directory does not exist: dir]\n", 
3300
			// not the best diagnostic we could imagine
3301
		true);
3302
}
3303
3304
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=146554
3305
// per source directory output directory
3306
// -bootclasspath dir[-d dir] is forbidden
3307
public void test067_per_source_output_directory(){
3308
	this.runNegativeTest(
3309
		new String[] {
3310
			"X.java",
3311
			"public class X {\n" +
3312
			"  Zork z;\n" +
3313
			"}"},
3314
        "\"" + OUTPUT_DIR +  File.separator + 
3315
        	"X.java\""
3316
        + " -1.5"
3317
        + " -cp \"" + OUTPUT_DIR + "\"" + "[-d dir]",
3318
		"", 
3319
		"directory does not exist: dir]\n", 
3320
			// not the best diagnostic we could imagine
3321
		true);
3322
}
3323
3324
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=146554
3325
// per source directory output directory
3326
// new case 3: overriding -d none for one of the sources
3327
public void test068_per_source_output_directory(){
3328
	String source1 = "src1",
3329
		output1 = "bin1", output2 = "bin2";
3330
	this.runConformTest(
3331
		new String[] {
3332
			source1 + File.separator + "/X.java",
3333
			"public class X {}",
3334
			"Z.java",
3335
			"public class Z {\n" +
3336
			"  X f;\n" +
3337
			"}",
3338
        },
3339
        "\"" + OUTPUT_DIR +  File.separator + 
3340
        	"Z.java\""
3341
        + " -1.5"
3342
        + " -sourcepath \"" + OUTPUT_DIR + File.separator + source1 + "\""
3343
        + "[-d \"" + OUTPUT_DIR + File.separator + output1 + "\"]"
3344
        + " -d none",
3345
		"", 
3346
		"",
3347
		true);
3348
	String fileName = OUTPUT_DIR + File.separator + output1 + 
3349
			File.separator + "X.class";
3350
	assertTrue("missing file: " + fileName, (new File(fileName)).exists());
3351
	fileName = OUTPUT_DIR + File.separator + source1 + 
3352
			File.separator + "X.class";
3353
	assertFalse("extraneous file: " + fileName, (new File(fileName)).exists());
3354
	fileName = OUTPUT_DIR + File.separator + output2 + 
3355
			File.separator + "X.class";
3356
	assertFalse("extraneous file: " + fileName, (new File(fileName)).exists());
3357
	fileName = OUTPUT_DIR + File.separator + output2 + 
3358
			File.separator + "Z.class";
3359
	assertFalse("extraneous file: " + fileName, (new File(fileName)).exists());
3360
}
3361
3049
public static Class testClass() {
3362
public static Class testClass() {
3050
	return BatchCompilerTest.class;
3363
	return BatchCompilerTest.class;
3051
}
3364
}
(-)batch/org/eclipse/jdt/internal/compiler/batch/messages.properties (-3 / +7 lines)
Lines 117-126 Link Here
117
\    -sourcepath <directories and zip/jar files separated by {0}>\n\
117
\    -sourcepath <directories and zip/jar files separated by {0}>\n\
118
\                       specify location for application sources. Each directory\n\
118
\                       specify location for application sources. Each directory\n\
119
\                       or file can specify access rules for types between ''[''\n\
119
\                       or file can specify access rules for types between ''[''\n\
120
\                       and '']''.\n\
120
\                       and '']''. Each directory can further specify a specific\n\
121
\                       destination directory using a ''-d'' option between ''[''\n\
122
\                       and '']''; this overrides the general ''-d'' option.\n\
121
\                       .class files created from source files contained in a\n\
123
\                       .class files created from source files contained in a\n\
122
\                       jar file are put in the user.dir folder in case no\n\
124
\                       jar file are put in the user.dir folder in case no\n\
123
\                       destination directory is specified.\n\
125
\                       general ''-d'' option is specified. zip/jar files cannot\n\
126
\                       override the general ''-d'' option\n\
124
\    -extdirs <directories separated by {0}>\n\
127
\    -extdirs <directories separated by {0}>\n\
125
\                       specify location for extension zip/jar files\n\
128
\                       specify location for extension zip/jar files\n\
126
\    -endorseddirs <directories separated by {0}>\n\
129
\    -endorseddirs <directories separated by {0}>\n\
Lines 142-148 Link Here
142
\    -1.6               use 1.6 compliance level (implicit -source 1.6\n\
145
\    -1.6               use 1.6 compliance level (implicit -source 1.6\n\
143
\                       -target 1.6)\n\
146
\                       -target 1.6)\n\
144
\    -source <version>  set source level: 1.3 to 1.6 (or 5, 5.0, 6 or 6.0)\n\
147
\    -source <version>  set source level: 1.3 to 1.6 (or 5, 5.0, 6 or 6.0)\n\
145
\    -target <version>  set classfile target level: 1.1 to 1.6 (or 5, 5.0, 6 or 6.0)\n\
148
\    -target <version>  set classfile target level: 1.1 to 1.6 (or 5, 5.0, 6\n\
149
\                       or 6.0)\n\
146
\ \n\
150
\ \n\
147
\ Warning options:\n\
151
\ Warning options:\n\
148
\    -deprecation     + deprecation outside deprecated code\n\
152
\    -deprecation     + deprecation outside deprecated code\n\
(-)batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java (-5 / +14 lines)
Lines 94-109 Link Here
94
	initializeKnownFileNames(initialFileNames);
94
	initializeKnownFileNames(initialFileNames);
95
}
95
}
96
static Classpath getClasspath(String classpathName, String encoding, AccessRuleSet accessRuleSet) {
96
static Classpath getClasspath(String classpathName, String encoding, AccessRuleSet accessRuleSet) {
97
	return getClasspath(classpathName, encoding, false, accessRuleSet);
97
	return getClasspath(classpathName, encoding, false, accessRuleSet, null);
98
}
98
}
99
static Classpath getClasspath(String classpathName, String encoding, boolean isSourceOnly, AccessRuleSet accessRuleSet) {
99
static Classpath getClasspath(String classpathName, String encoding, 
100
		boolean isSourceOnly, AccessRuleSet accessRuleSet, 
101
		String outputDirName) {
100
	Classpath result = null;
102
	Classpath result = null;
101
	File file = new File(convertPathSeparators(classpathName));
103
	File file = new File(convertPathSeparators(classpathName));
102
	if (file.isDirectory()) {
104
	if (file.isDirectory()) {
103
		if (file.exists()) {
105
		if (file.exists()) {
104
			result = new ClasspathDirectory(file, encoding, isSourceOnly ? ClasspathLocation.SOURCE : ClasspathLocation.SOURCE | ClasspathLocation.BINARY, accessRuleSet);
106
			result = new ClasspathDirectory(file, encoding, 
105
		}
107
					isSourceOnly ? ClasspathLocation.SOURCE : 
106
	} else {
108
						ClasspathLocation.SOURCE | ClasspathLocation.BINARY, 
109
					accessRuleSet,
110
					outputDirName == null ? null :
111
						new File(convertPathSeparators(outputDirName)));
112
		}
113
	} else if (outputDirName == null) { 
114
			// should not be non null for non directory entries (unless -d 
115
			// option becomes supported for jar/zip entries)
107
		String lowercaseClasspathName = classpathName.toLowerCase();
116
		String lowercaseClasspathName = classpathName.toLowerCase();
108
		if (lowercaseClasspathName.endsWith(SUFFIX_STRING_jar)
117
		if (lowercaseClasspathName.endsWith(SUFFIX_STRING_jar)
109
				|| lowercaseClasspathName.endsWith(SUFFIX_STRING_zip)) {
118
				|| lowercaseClasspathName.endsWith(SUFFIX_STRING_zip)) {
(-)batch/org/eclipse/jdt/internal/compiler/batch/Main.java (-41 / +139 lines)
Lines 1014-1019 Link Here
1014
	public final static String bundleName =
1014
	public final static String bundleName =
1015
		"org.eclipse.jdt.internal.compiler.batch.messages"; 	//$NON-NLS-1$
1015
		"org.eclipse.jdt.internal.compiler.batch.messages"; 	//$NON-NLS-1$
1016
1016
1017
	public static final String NONE = "none"; //$NON-NLS-1$
1017
	static {
1018
	static {
1018
		relocalize();
1019
		relocalize();
1019
	}
1020
	}
Lines 1171-1177 Link Here
1171
	}
1172
	}
1172
}
1173
}
1173
1174
1174
private void addNewEntry(ArrayList paths, String currentClasspathName, ArrayList currentRuleSpecs, String customEncoding, boolean isSourceOnly) {
1175
private void addNewEntry(ArrayList paths, String currentClasspathName, 
1176
		ArrayList currentRuleSpecs, String customEncoding, String outputDirName, 
1177
		boolean isSourceOnly) {
1175
	AccessRule[] accessRules = new AccessRule[currentRuleSpecs.size()];
1178
	AccessRule[] accessRules = new AccessRule[currentRuleSpecs.size()];
1176
	boolean rulesOK = true;
1179
	boolean rulesOK = true;
1177
	Iterator i = currentRuleSpecs.iterator();
1180
	Iterator i = currentRuleSpecs.iterator();
Lines 1227-1233 Link Here
1227
				currentClasspathName,
1230
				currentClasspathName,
1228
				customEncoding,
1231
				customEncoding,
1229
				isSourceOnly,
1232
				isSourceOnly,
1230
				accessRuleSet);
1233
				accessRuleSet,
1234
				outputDirName);
1231
		if (currentClasspath != null) {
1235
		if (currentClasspath != null) {
1232
			paths.add(currentClasspath);
1236
			paths.add(currentClasspath);
1233
		} else {
1237
		} else {
Lines 1322-1333 Link Here
1322
	final int INSIDE_BOOTCLASSPATH = 8;
1326
	final int INSIDE_BOOTCLASSPATH = 8;
1323
	final int INSIDE_MAX_PROBLEMS = 9;
1327
	final int INSIDE_MAX_PROBLEMS = 9;
1324
	final int INSIDE_EXT_DIRS = 10;
1328
	final int INSIDE_EXT_DIRS = 10;
1325
	final int INSIDE_SOURCE_PATH = 11;
1329
	final int INSIDE_SOURCE_PATH_start = 11;
1330
	final int INSIDE_SOURCE_PATH_bracket = 13;
1326
	final int INSIDE_ENDORSED_DIRS = 12;
1331
	final int INSIDE_ENDORSED_DIRS = 12;
1327
1332
1328
	final int DEFAULT = 0;
1333
	final int DEFAULT = 0;
1329
	final int DEFAULT_SIZE_CLASSPATH = 4;
1334
	final int DEFAULT_SIZE_CLASSPATH = 4;
1330
	ArrayList bootclasspaths = new ArrayList(DEFAULT_SIZE_CLASSPATH);
1335
	ArrayList bootclasspaths = new ArrayList(DEFAULT_SIZE_CLASSPATH);
1336
	String sourcepathClasspathArg = null;
1331
	ArrayList sourcepathClasspaths = new ArrayList(DEFAULT_SIZE_CLASSPATH);
1337
	ArrayList sourcepathClasspaths = new ArrayList(DEFAULT_SIZE_CLASSPATH);
1332
	ArrayList classpaths = new ArrayList(DEFAULT_SIZE_CLASSPATH);
1338
	ArrayList classpaths = new ArrayList(DEFAULT_SIZE_CLASSPATH);
1333
	ArrayList extdirsClasspaths = null;
1339
	ArrayList extdirsClasspaths = null;
Lines 1412-1419 Link Here
1412
		switch(mode) {
1418
		switch(mode) {
1413
			case DEFAULT :
1419
			case DEFAULT :
1414
				customEncoding = null;
1420
				customEncoding = null;
1415
				if (currentArg.endsWith("]") && !(mode == INSIDE_BOOTCLASSPATH || mode == INSIDE_CLASSPATH || //$NON-NLS-1$ 
1421
				if (currentArg.endsWith("]") && !(mode == INSIDE_BOOTCLASSPATH || mode == INSIDE_CLASSPATH //$NON-NLS-1$ 
1416
						mode == INSIDE_SOURCE_PATH) ) {
1422
						) ) {
1417
					// look for encoding specification
1423
					// look for encoding specification
1418
					int encodingStart = currentArg.indexOf('[') + 1;
1424
					int encodingStart = currentArg.indexOf('[') + 1;
1419
					int encodingEnd = currentArg.length() - 1;
1425
					int encodingEnd = currentArg.length() - 1;
Lines 1560-1566 Link Here
1560
					continue;
1566
					continue;
1561
				}
1567
				}
1562
				if (currentArg.equals("-sourcepath")) {//$NON-NLS-1$
1568
				if (currentArg.equals("-sourcepath")) {//$NON-NLS-1$
1563
					if (sourcepathClasspaths.size() > 0) {
1569
					if (sourcepathClasspathArg != null) {
1564
						StringBuffer errorMessage = new StringBuffer();
1570
						StringBuffer errorMessage = new StringBuffer();
1565
						errorMessage.append(currentArg);
1571
						errorMessage.append(currentArg);
1566
						if ((index + 1) < argCount) {
1572
						if ((index + 1) < argCount) {
Lines 1570-1576 Link Here
1570
						throw new InvalidInputException(
1576
						throw new InvalidInputException(
1571
							Main.bind("configure.duplicateSourcepath", errorMessage.toString())); //$NON-NLS-1$
1577
							Main.bind("configure.duplicateSourcepath", errorMessage.toString())); //$NON-NLS-1$
1572
					}
1578
					}
1573
					mode = INSIDE_SOURCE_PATH;
1579
					mode = INSIDE_SOURCE_PATH_start;
1574
					continue;
1580
					continue;
1575
				}
1581
				}
1576
				if (currentArg.equals("-extdirs")) {//$NON-NLS-1$
1582
				if (currentArg.equals("-extdirs")) {//$NON-NLS-1$
Lines 1692-1698 Link Here
1692
						this.options.put(
1698
						this.options.put(
1693
							CompilerOptions.OPTION_SourceFileAttribute,
1699
							CompilerOptions.OPTION_SourceFileAttribute,
1694
							CompilerOptions.DO_NOT_GENERATE);
1700
							CompilerOptions.DO_NOT_GENERATE);
1695
						if (length == 7 && debugOption.equals("-g:none")) //$NON-NLS-1$
1701
						if (length == 7 && debugOption.equals("-g:" + NONE)) //$NON-NLS-1$
1696
							continue;
1702
							continue;
1697
						StringTokenizer tokenizer =
1703
						StringTokenizer tokenizer =
1698
							new StringTokenizer(debugOption.substring(3, debugOption.length()), ","); //$NON-NLS-1$
1704
							new StringTokenizer(debugOption.substring(3, debugOption.length()), ","); //$NON-NLS-1$
Lines 1729-1735 Link Here
1729
					mode = DEFAULT;
1735
					mode = DEFAULT;
1730
					String warningOption = currentArg;
1736
					String warningOption = currentArg;
1731
					int length = currentArg.length();
1737
					int length = currentArg.length();
1732
					if (length == 10 && warningOption.equals("-warn:none")) { //$NON-NLS-1$
1738
					if (length == 10 && warningOption.equals("-warn:" + NONE)) { //$NON-NLS-1$
1733
						disableWarnings();
1739
						disableWarnings();
1734
						continue;
1740
						continue;
1735
					}
1741
					}
Lines 2230-2238 Link Here
2230
				bootclasspaths.add(currentArg);
2236
				bootclasspaths.add(currentArg);
2231
				mode = DEFAULT;
2237
				mode = DEFAULT;
2232
				continue;
2238
				continue;
2233
			case INSIDE_SOURCE_PATH :
2239
			case INSIDE_SOURCE_PATH_start:
2234
				sourcepathClasspaths.add(currentArg);
2240
				sourcepathClasspathArg = currentArg;
2235
				mode = DEFAULT;
2241
				mode = DEFAULT;
2242
				char[] currentArgChars = currentArg.toCharArray();
2243
				for (int i = 0, length = currentArgChars.length; i < length; 
2244
						i++) {
2245
					switch (currentArgChars[i]) {
2246
						case '[':
2247
							if (mode == INSIDE_SOURCE_PATH_bracket) {
2248
								// WORK error
2249
							} else {
2250
								mode = INSIDE_SOURCE_PATH_bracket;
2251
							}
2252
							break;
2253
						case ']':
2254
							if (mode != INSIDE_SOURCE_PATH_bracket) {
2255
								// WORK error
2256
							} else {
2257
								mode = DEFAULT;
2258
							}
2259
							break;
2260
					}
2261
				}
2262
				continue;
2263
			case INSIDE_SOURCE_PATH_bracket:
2264
				sourcepathClasspathArg += " " + currentArg; //$NON-NLS-1$
2265
				mode = DEFAULT;
2266
				currentArgChars = currentArg.toCharArray();
2267
				for (int i = 0, length = currentArgChars.length; i < length; 
2268
						i++) {
2269
					switch (currentArgChars[i]) {
2270
						case '[':
2271
							if (mode == INSIDE_SOURCE_PATH_bracket) {
2272
								// WORK error
2273
							} else {
2274
								mode = INSIDE_SOURCE_PATH_bracket;
2275
							}
2276
							break;
2277
						case ']':
2278
							if (mode != INSIDE_SOURCE_PATH_bracket) {
2279
								// WORK error
2280
							} else {
2281
								mode = DEFAULT;
2282
							}
2283
							break;
2284
					}
2285
				}
2236
				continue;
2286
				continue;
2237
			case INSIDE_EXT_DIRS :
2287
			case INSIDE_EXT_DIRS :
2238
				StringTokenizer tokenizer = new StringTokenizer(currentArg,	File.pathSeparator, false);
2288
				StringTokenizer tokenizer = new StringTokenizer(currentArg,	File.pathSeparator, false);
Lines 2360-2368 Link Here
2360
					if (current != null) {
2410
					if (current != null) {
2361
						for (int j = 0, max2 = current.length; j < max2; j++) {
2411
						for (int j = 0, max2 = current.length; j < max2; j++) {
2362
							FileSystem.Classpath classpath = 
2412
							FileSystem.Classpath classpath = 
2363
								FileSystem.getClasspath(
2413
								FileSystem.getClasspath(current[j].getAbsolutePath(),
2364
									current[j].getAbsolutePath(),
2414
									null, false, null, null); 
2365
									null, false, null); 
2366
							if (classpath != null) {
2415
							if (classpath != null) {
2367
								bootclasspaths.add(classpath);
2416
								bootclasspaths.add(classpath);
2368
							}
2417
							}
Lines 2402-2415 Link Here
2402
			}
2451
			}
2403
		}
2452
		}
2404
	}
2453
	}
2405
	final int sourcepathClasspathsSize = sourcepathClasspaths.size();
2454
	if (sourcepathClasspathArg != null) {
2406
	if (sourcepathClasspathsSize != 0) {
2455
		processPathEntries(DEFAULT_SIZE_CLASSPATH, sourcepathClasspaths, 
2407
		String[] paths = new String[sourcepathClasspathsSize];
2456
			sourcepathClasspathArg, customEncoding, true);
2408
		sourcepathClasspaths.toArray(paths);
2409
		sourcepathClasspaths.clear();
2410
		for (int i = 0; i < sourcepathClasspathsSize; i++) {
2411
			processPathEntries(DEFAULT_SIZE_CLASSPATH, sourcepathClasspaths, paths[i], customEncoding, true);
2412
		}			
2413
	}
2457
	}
2414
	
2458
	
2415
	if (filesCount != 0)
2459
	if (filesCount != 0)
Lines 2538-2544 Link Here
2538
2582
2539
	if (this.destinationPath == null) {
2583
	if (this.destinationPath == null) {
2540
		this.generatePackagesStructure = false;
2584
		this.generatePackagesStructure = false;
2541
	} else if ("none".equals(this.destinationPath)) { //$NON-NLS-1$
2585
	} else if (NONE.equals(this.destinationPath)) {
2542
		this.destinationPath = null;
2586
		this.destinationPath = null;
2543
	}
2587
	}
2544
	
2588
	
Lines 2802-2811 Link Here
2802
public void outputClassFiles(CompilationResult unitResult) {
2846
public void outputClassFiles(CompilationResult unitResult) {
2803
	if (!((unitResult == null) || (unitResult.hasErrors() && !this.proceedOnError))) {
2847
	if (!((unitResult == null) || (unitResult.hasErrors() && !this.proceedOnError))) {
2804
		ClassFile[] classFiles = unitResult.getClassFiles();
2848
		ClassFile[] classFiles = unitResult.getClassFiles();
2805
		if (!this.generatePackagesStructure) {
2849
		String currentDestinationPath = null;
2806
			this.destinationPath = extractDestinationPathFromSourceFile(unitResult);
2850
		boolean currentGenerateClasspathStructure = false;
2851
		ClasspathDirectory classpathDirectory;
2852
		if ((classpathDirectory = ((CompilationUnit)unitResult.compilationUnit).
2853
				classpathDirectory) != null) {
2854
			currentDestinationPath = classpathDirectory.
2855
				getOutputDirectoryPath();
2856
			currentGenerateClasspathStructure = true;
2857
		}
2858
		if (currentDestinationPath == null) {
2859
			if (this.generatePackagesStructure) {
2860
				currentDestinationPath = this.destinationPath;
2861
				currentGenerateClasspathStructure = true;
2862
			} else {
2863
				currentDestinationPath = 
2864
					extractDestinationPathFromSourceFile(unitResult);
2865
			}
2807
		}
2866
		}
2808
		if (this.destinationPath != null) {
2867
		if (currentDestinationPath != null) {
2809
			for (int i = 0, fileCount = classFiles.length; i < fileCount; i++) {
2868
			for (int i = 0, fileCount = classFiles.length; i < fileCount; i++) {
2810
				// retrieve the key and the corresponding classfile
2869
				// retrieve the key and the corresponding classfile
2811
				ClassFile classFile = classFiles[i];
2870
				ClassFile classFile = classFiles[i];
Lines 2826-2844 Link Here
2826
									relativeStringName
2885
									relativeStringName
2827
								}));
2886
								}));
2828
					ClassFile.writeToDisk(
2887
					ClassFile.writeToDisk(
2829
						this.generatePackagesStructure,
2888
						currentGenerateClasspathStructure,
2830
						this.destinationPath,
2889
						currentDestinationPath,
2831
						relativeStringName,
2890
						relativeStringName,
2832
						classFile);
2891
						classFile);
2833
					LookupEnvironment env = this.batchCompiler.lookupEnvironment;
2892
					LookupEnvironment env = this.batchCompiler.lookupEnvironment;
2834
					if (classFile.isShared) env.classFilePool.release(classFile);
2893
					if (classFile.isShared) env.classFilePool.release(classFile);
2835
					this.logger.logClassFile(
2894
					this.logger.logClassFile(
2836
						this.generatePackagesStructure,
2895
						currentGenerateClasspathStructure,
2837
						this.destinationPath,
2896
						currentDestinationPath,
2838
						relativeStringName);
2897
						relativeStringName);
2839
					this.exportedClassFilesCounter++;
2898
					this.exportedClassFilesCounter++;
2840
				} catch (IOException e) {
2899
				} catch (IOException e) {
2841
					this.logger.logNoClassFileCreated(this.destinationPath, relativeStringName, e);
2900
					this.logger.logNoClassFileCreated(currentDestinationPath, relativeStringName, e);
2842
				}
2901
				}
2843
			}
2902
			}
2844
		}
2903
		}
Lines 2895-2902 Link Here
2895
	this.logger.flush();
2954
	this.logger.flush();
2896
}
2955
}
2897
2956
2898
private void processPathEntries(final int defaultSize, final ArrayList paths, final String currentPath, String customEncoding, boolean isSourceOnly) {
2957
private void processPathEntries(final int defaultSize, final ArrayList paths, 
2958
		final String currentPath, String customEncoding, boolean isSourceOnly) {
2899
	String currentClasspathName = null;
2959
	String currentClasspathName = null;
2960
	String currentOutputDirName = null;
2900
	ArrayList currentRuleSpecs = new ArrayList(defaultSize);
2961
	ArrayList currentRuleSpecs = new ArrayList(defaultSize);
2901
	StringTokenizer tokenizer = new StringTokenizer(currentPath,
2962
	StringTokenizer tokenizer = new StringTokenizer(currentPath,
2902
			File.pathSeparator + "[]", true); //$NON-NLS-1$
2963
			File.pathSeparator + "[]", true); //$NON-NLS-1$
Lines 2914-2933 Link Here
2914
	// 'path[' 'path1;path2['
2975
	// 'path[' 'path1;path2['
2915
	final int rulesReadyToClose = 6;
2976
	final int rulesReadyToClose = 6;
2916
	// 'path[rule' 'path[rule1;rule2'
2977
	// 'path[rule' 'path[rule1;rule2'
2978
	final int outputDirReadyToClose = 7;
2979
	// 'path[-d bin'
2980
	final int readyToCloseEndingWithOutputDir = 8;
2981
	// 'path[-d bin]' 'path[rule][-d bin]'
2982
	final int outputDirStart = 9;
2983
	// 'path[rule]['
2917
	final int error = 99;
2984
	final int error = 99;
2918
	int state = start;
2985
	int state = start;
2919
	String token = null;
2986
	String token = null;
2920
	while (tokenizer.hasMoreTokens()) {
2987
	while (tokenizer.hasMoreTokens() && state != error) {
2921
		token = tokenizer.nextToken();
2988
		token = tokenizer.nextToken();
2922
		if (token.equals(File.pathSeparator)) {
2989
		if (token.equals(File.pathSeparator)) {
2923
			switch (state) {
2990
			switch (state) {
2924
			case start:
2991
			case start:
2992
			case readyToCloseOrOtherEntry:
2925
				break;
2993
				break;
2926
			case readyToClose:
2994
			case readyToClose:
2927
			case readyToCloseEndingWithRules:
2995
			case readyToCloseEndingWithRules:
2928
			case readyToCloseOrOtherEntry:
2996
			case readyToCloseEndingWithOutputDir:
2929
				state = readyToCloseOrOtherEntry;
2997
				state = readyToCloseOrOtherEntry;
2930
				addNewEntry(paths, currentClasspathName, currentRuleSpecs, customEncoding, isSourceOnly);
2998
				addNewEntry(paths, currentClasspathName, currentRuleSpecs, 
2999
						customEncoding, currentOutputDirName, isSourceOnly);
2931
				currentRuleSpecs.clear();
3000
				currentRuleSpecs.clear();
2932
				break;
3001
				break;
2933
			case rulesReadyToClose:
3002
			case rulesReadyToClose:
Lines 2941-2946 Link Here
2941
			case readyToClose:
3010
			case readyToClose:
2942
				state = rulesStart;
3011
				state = rulesStart;
2943
				break;
3012
				break;
3013
			case readyToCloseEndingWithRules:
3014
				state = outputDirStart;
3015
				break;
2944
			default:
3016
			default:
2945
				state = error;
3017
				state = error;
2946
			}
3018
			}
Lines 2949-2958 Link Here
2949
			case rulesReadyToClose:
3021
			case rulesReadyToClose:
2950
				state = readyToCloseEndingWithRules;
3022
				state = readyToCloseEndingWithRules;
2951
				break;
3023
				break;
3024
			case outputDirReadyToClose:
3025
				state = readyToCloseEndingWithOutputDir;
3026
				break;
2952
			default:
3027
			default:
2953
				state = error;
3028
				state = error;
2954
			}
3029
			}
2955
2956
		} else {
3030
		} else {
2957
			// regular word
3031
			// regular word
2958
			switch (state) {
3032
			switch (state) {
Lines 2961-2981 Link Here
2961
				state = readyToClose;
3035
				state = readyToClose;
2962
				currentClasspathName = token;
3036
				currentClasspathName = token;
2963
				break;
3037
				break;
2964
			case rulesNeedAnotherRule:
2965
			case rulesStart:
3038
			case rulesStart:
3039
				if (token.startsWith("-d ")) { //$NON-NLS-1$
3040
					currentOutputDirName = token.substring(3).trim();
3041
					if (NONE.equals(currentOutputDirName)) {
3042
						state = error;
3043
					} else {
3044
						state = outputDirReadyToClose;
3045
					}
3046
					break;
3047
				} // else we proceed with a rule
3048
			case rulesNeedAnotherRule:
2966
				state = rulesReadyToClose;
3049
				state = rulesReadyToClose;
2967
				currentRuleSpecs.add(token);
3050
				currentRuleSpecs.add(token);
2968
				break;
3051
				break;
3052
			case outputDirStart:
3053
				if (!token.startsWith("-d ")) { //$NON-NLS-1$
3054
					state = error;
3055
				} else {
3056
					currentOutputDirName = token.substring(3).trim();
3057
					if (NONE.equals(currentOutputDirName)) {
3058
						state = error;
3059
					} else {
3060
						state = outputDirReadyToClose;
3061
					}
3062
				}
3063
				break;
2969
			default:
3064
			default:
2970
				state = error;
3065
				state = error;
2971
			}
3066
			}
2972
		}
3067
		}
2973
	}
3068
	}
2974
	switch(state) {
3069
	switch(state) {
2975
		case readyToClose :
3070
		case readyToCloseOrOtherEntry:
2976
		case readyToCloseEndingWithRules :
3071
			break;
2977
		case readyToCloseOrOtherEntry :
3072
		case readyToClose:
2978
			addNewEntry(paths, currentClasspathName, currentRuleSpecs, customEncoding, isSourceOnly);
3073
		case readyToCloseEndingWithRules:
3074
		case readyToCloseEndingWithOutputDir:
3075
			addNewEntry(paths, currentClasspathName, currentRuleSpecs, 
3076
				customEncoding, currentOutputDirName, isSourceOnly);
2979
			break;
3077
			break;
2980
		default :
3078
		default :
2981
			// we go on anyway
3079
			// we go on anyway
(-)batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java (-3 / +11 lines)
Lines 28-35 Link Here
28
private String[] missingPackageHolder = new String[1];
28
private String[] missingPackageHolder = new String[1];
29
private int mode; // ability to only consider one kind of files (source vs. binaries), by default use both
29
private int mode; // ability to only consider one kind of files (source vs. binaries), by default use both
30
private String encoding; // only useful if referenced in the source path
30
private String encoding; // only useful if referenced in the source path
31
private String outputDirectoryPath; // only carried by sourcepath arguments
31
32
32
ClasspathDirectory(File directory, String encoding, int mode, AccessRuleSet accessRuleSet) {
33
ClasspathDirectory(File directory, String encoding, int mode, 
34
		AccessRuleSet accessRuleSet, File outputDirectory) {
33
	super(accessRuleSet);
35
	super(accessRuleSet);
34
	this.mode = mode;
36
	this.mode = mode;
35
	this.path = directory.getAbsolutePath();
37
	this.path = directory.getAbsolutePath();
Lines 37-42 Link Here
37
		this.path += File.separator;
39
		this.path += File.separator;
38
	this.directoryCache = new Hashtable(11);
40
	this.directoryCache = new Hashtable(11);
39
	this.encoding = encoding;
41
	this.encoding = encoding;
42
	if (outputDirectory != null) {
43
		this.outputDirectoryPath = outputDirectory.getAbsolutePath();
44
	}
40
}
45
}
41
String[] directoryList(String qualifiedPackageName) {
46
String[] directoryList(String qualifiedPackageName) {
42
	String[] dirList = (String[]) this.directoryCache.get(qualifiedPackageName);
47
	String[] dirList = (String[]) this.directoryCache.get(qualifiedPackageName);
Lines 88-101 Link Here
88
		String fullSourcePath = this.path + qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - 6)  + SUFFIX_STRING_java;
93
		String fullSourcePath = this.path + qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - 6)  + SUFFIX_STRING_java;
89
		if (!binaryExists)
94
		if (!binaryExists)
90
			return new NameEnvironmentAnswer(new CompilationUnit(null,
95
			return new NameEnvironmentAnswer(new CompilationUnit(null,
91
					fullSourcePath, this.encoding),
96
					fullSourcePath, this.encoding, this),
92
					fetchAccessRestriction(qualifiedBinaryFileName));
97
					fetchAccessRestriction(qualifiedBinaryFileName));
93
		String fullBinaryPath = this.path + qualifiedBinaryFileName;
98
		String fullBinaryPath = this.path + qualifiedBinaryFileName;
94
		long binaryModified = new File(fullBinaryPath).lastModified();
99
		long binaryModified = new File(fullBinaryPath).lastModified();
95
		long sourceModified = new File(fullSourcePath).lastModified();
100
		long sourceModified = new File(fullSourcePath).lastModified();
96
		if (sourceModified > binaryModified)
101
		if (sourceModified > binaryModified)
97
			return new NameEnvironmentAnswer(new CompilationUnit(null,
102
			return new NameEnvironmentAnswer(new CompilationUnit(null,
98
					fullSourcePath, this.encoding),
103
					fullSourcePath, this.encoding, this),
99
					fetchAccessRestriction(qualifiedBinaryFileName));
104
					fetchAccessRestriction(qualifiedBinaryFileName));
100
	}
105
	}
101
	if (binaryExists) {
106
	if (binaryExists) {
Lines 132-137 Link Here
132
	}
137
	}
133
	return this.normalizedPath;
138
	return this.normalizedPath;
134
}
139
}
140
public String getOutputDirectoryPath() {
141
	return this.outputDirectoryPath;
142
}
135
public String getPath() {
143
public String getPath() {
136
	return this.path;
144
	return this.path;
137
}
145
}
(-)batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java (+8 lines)
Lines 23-30 Link Here
23
	public char[] fileName;
23
	public char[] fileName;
24
	public char[] mainTypeName;
24
	public char[] mainTypeName;
25
	String encoding;
25
	String encoding;
26
	public ClasspathDirectory classpathDirectory;
26
	
27
	
27
public CompilationUnit(char[] contents, String fileName, String encoding) {
28
public CompilationUnit(char[] contents, String fileName, String encoding) {
29
	this(contents, fileName, encoding, null);
30
}
31
public CompilationUnit(char[] contents, String fileName, String encoding,
32
		ClasspathDirectory classpathDirectory) {
28
	this.contents = contents;
33
	this.contents = contents;
29
	char[] fileNameCharArray = fileName.toCharArray();
34
	char[] fileNameCharArray = fileName.toCharArray();
30
	switch(File.separatorChar) {
35
	switch(File.separatorChar) {
Lines 48-53 Link Here
48
53
49
	this.mainTypeName = CharOperation.subarray(fileNameCharArray, start, end);
54
	this.mainTypeName = CharOperation.subarray(fileNameCharArray, start, end);
50
	this.encoding = encoding;
55
	this.encoding = encoding;
56
	this.classpathDirectory = classpathDirectory;
57
		// set to null for all compilation unit locations but classpath 
58
		// directories
51
}
59
}
52
public char[] getContents() {
60
public char[] getContents() {
53
	if (this.contents != null)
61
	if (this.contents != null)

Return to bug 146554