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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (+17 lines)
Lines 3039-3044 Link Here
3039
			"/out/p cannot be used as output directory\n",
3039
			"/out/p cannot be used as output directory\n",
3040
		true);
3040
		true);
3041
}
3041
}
3042
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=161996
3043
public void test057(){
3044
	this.runConformTest(
3045
			new String[] {
3046
					"X.java",
3047
					"/** */\n" + 
3048
					"public class X {\n" + 
3049
					"}",
3050
				},
3051
        "\"" + OUTPUT_DIR +  File.separator + "X.java\""
3052
        + " -cp " + "\"" + OUTPUT_DIR + File.separator + "[square][bracket].jar" + "\""
3053
        + " -d \"" + OUTPUT_DIR + "\"",
3054
        "",
3055
        "",
3056
        true);
3057
}
3058
3042
public static Class testClass() {
3059
public static Class testClass() {
3043
	return BatchCompilerTest.class;
3060
	return BatchCompilerTest.class;
3044
}
3061
}
(-)batch/org/eclipse/jdt/internal/compiler/batch/Main.java (-35 / +66 lines)
Lines 28-36 Link Here
28
import java.text.MessageFormat;
28
import java.text.MessageFormat;
29
import java.util.ArrayList;
29
import java.util.ArrayList;
30
import java.util.Arrays;
30
import java.util.Arrays;
31
import java.util.Collections;
31
import java.util.Date;
32
import java.util.Date;
32
import java.util.HashMap;
33
import java.util.HashMap;
33
import java.util.Iterator;
34
import java.util.Iterator;
35
import java.util.LinkedList;
34
import java.util.Locale;
36
import java.util.Locale;
35
import java.util.Map;
37
import java.util.Map;
36
import java.util.MissingResourceException;
38
import java.util.MissingResourceException;
Lines 40-47 Link Here
40
42
41
import org.eclipse.jdt.core.compiler.CategorizedProblem;
43
import org.eclipse.jdt.core.compiler.CategorizedProblem;
42
import org.eclipse.jdt.core.compiler.CharOperation;
44
import org.eclipse.jdt.core.compiler.CharOperation;
43
import org.eclipse.jdt.core.compiler.InvalidInputException;
44
import org.eclipse.jdt.core.compiler.IProblem;
45
import org.eclipse.jdt.core.compiler.IProblem;
46
import org.eclipse.jdt.core.compiler.InvalidInputException;
45
import org.eclipse.jdt.internal.compiler.ClassFile;
47
import org.eclipse.jdt.internal.compiler.ClassFile;
46
import org.eclipse.jdt.internal.compiler.CompilationResult;
48
import org.eclipse.jdt.internal.compiler.CompilationResult;
47
import org.eclipse.jdt.internal.compiler.Compiler;
49
import org.eclipse.jdt.internal.compiler.Compiler;
Lines 59-67 Link Here
59
import org.eclipse.jdt.internal.compiler.problem.DefaultProblem;
61
import org.eclipse.jdt.internal.compiler.problem.DefaultProblem;
60
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
62
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
61
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
63
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
64
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
62
import org.eclipse.jdt.internal.compiler.util.Messages;
65
import org.eclipse.jdt.internal.compiler.util.Messages;
63
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
66
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
64
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
65
import org.eclipse.jdt.internal.compiler.util.Util;
67
import org.eclipse.jdt.internal.compiler.util.Util;
66
68
67
public class Main implements ProblemSeverities, SuffixConstants {
69
public class Main implements ProblemSeverities, SuffixConstants {
Lines 2989-3044 Link Here
2989
	ArrayList currentRuleSpecs = new ArrayList(defaultSize);
2991
	ArrayList currentRuleSpecs = new ArrayList(defaultSize);
2990
	StringTokenizer tokenizer = new StringTokenizer(currentPath,
2992
	StringTokenizer tokenizer = new StringTokenizer(currentPath,
2991
			File.pathSeparator + "[]", true); //$NON-NLS-1$
2993
			File.pathSeparator + "[]", true); //$NON-NLS-1$
2994
	LinkedList list = new LinkedList(Collections.list(tokenizer));
2995
	
2992
	// state machine
2996
	// state machine
2993
	final int start = 0; 
2997
	// process list in reverse order, start refers to end of list
2994
	final int readyToClose = 1;
2998
	final int start = 0;
2995
	// 'path' 'path1[rule];path2'
2999
	final int rulesStart = 1;
2996
	final int readyToCloseEndingWithRules = 2;
3000
	// ']' '];path'
2997
	// 'path[rule]' 'path1;path2[rule]'
3001
	final int rulesReadyToCloseOrOtherRule = 2;
2998
	final int readyToCloseOrOtherEntry = 3;
3002
	// 'rule]' 'rule1;rule2]'
2999
	// 'path[rule];' 'path;' 'path1;path2;'
3003
	final int rulesNeedAnotherRule = 3;
3000
	final int rulesNeedAnotherRule = 4;
3004
	// ';rule2]' ';rule2;rule3];path'
3001
	// 'path[rule1;'
3005
	final int readyForPath = 4;
3002
	final int rulesStart = 5;
3006
	// '[rule]' '[rule1;rule2]'
3003
	// 'path[' 'path1;path2['
3007
	final int readyToCloseOrOtherEntry = 5;
3004
	final int rulesReadyToClose = 6;
3008
	// 'path[rule]' 'path' 'path1;path2'
3005
	// 'path[rule' 'path[rule1;rule2'
3009
	final int readyForPathOrRules = 6;
3010
	// ';path[rule]' ';path'
3006
	final int error = 99;
3011
	final int error = 99;
3007
	int state = start;
3012
	int state = start;
3013
3008
	String token = null;
3014
	String token = null;
3009
	while (tokenizer.hasMoreTokens()) {
3015
	while (!list.isEmpty()) {
3010
		token = tokenizer.nextToken();
3016
		token = (String)list.removeLast();
3011
		if (token.equals(File.pathSeparator)) {
3017
		if (token.equals(File.pathSeparator)) {
3012
			switch (state) {
3018
			switch (state) {
3013
			case start:
3019
			case start:
3014
				break;
3020
				break;
3015
			case readyToClose:
3016
			case readyToCloseEndingWithRules:
3017
			case readyToCloseOrOtherEntry:
3021
			case readyToCloseOrOtherEntry:
3018
				state = readyToCloseOrOtherEntry;
3022
				Collections.reverse(currentRuleSpecs);
3019
				addNewEntry(paths, currentClasspathName, currentRuleSpecs, customEncoding, isSourceOnly);
3023
				addNewEntry(paths, currentClasspathName, currentRuleSpecs, customEncoding, isSourceOnly);
3020
				currentRuleSpecs.clear();
3024
				currentRuleSpecs.clear();
3025
				state = readyForPathOrRules;
3021
				break;
3026
				break;
3022
			case rulesReadyToClose:
3027
			case rulesReadyToCloseOrOtherRule:
3023
				state = rulesNeedAnotherRule;
3028
				state = rulesNeedAnotherRule;
3024
				break;
3029
				break;
3030
			case rulesNeedAnotherRule:
3031
				break;
3032
			case readyForPathOrRules:
3033
				break;
3025
			default:
3034
			default:
3026
				state = error;
3035
				state = error;
3027
			}
3036
			}
3028
		} else if (token.equals("[")) { //$NON-NLS-1$
3037
		} else if (token.equals("[")) { //$NON-NLS-1$
3029
			switch (state) {
3038
			switch (state) {
3030
			case readyToClose:
3039
			case start:
3031
				state = rulesStart;
3040
			case readyForPath:
3041
			case readyForPathOrRules:
3042
				currentClasspathName = getPath(list, token);
3043
				state = readyToCloseOrOtherEntry;
3032
				break;
3044
				break;
3033
			default:
3045
			case rulesReadyToCloseOrOtherRule:
3046
				state =  readyForPath;
3047
				break;
3048
			default:  
3034
				state = error;
3049
				state = error;
3035
			}
3050
			}
3036
		} else if (token.equals("]")) { //$NON-NLS-1$
3051
		} else if (token.equals("]")) { //$NON-NLS-1$
3037
			switch (state) {
3052
			switch (state) {
3038
			case rulesReadyToClose:
3053
			case start:
3039
				state = readyToCloseEndingWithRules;
3054
			case readyForPathOrRules:
3055
				state = rulesStart;
3040
				break;
3056
				break;
3041
			default:
3057
			case readyForPath:
3058
				currentClasspathName = getPath(list, token);
3059
				state = readyToCloseOrOtherEntry;
3060
				break;
3061
			default:  
3042
				state = error;
3062
				state = error;
3043
			}
3063
			}
3044
3064
Lines 3046-3069 Link Here
3046
			// regular word
3066
			// regular word
3047
			switch (state) {
3067
			switch (state) {
3048
			case start:
3068
			case start:
3049
			case readyToCloseOrOtherEntry:
3069
			case readyForPath:
3050
				state = readyToClose;
3070
			case readyForPathOrRules:
3051
				currentClasspathName = token;
3071
				currentClasspathName = getPath(list, token);
3072
				state = readyToCloseOrOtherEntry;
3052
				break;
3073
				break;
3053
			case rulesNeedAnotherRule:
3054
			case rulesStart:
3074
			case rulesStart:
3055
				state = rulesReadyToClose;
3075
			case rulesNeedAnotherRule:
3056
				currentRuleSpecs.add(token);
3076
				currentRuleSpecs.add(token);
3077
				state = rulesReadyToCloseOrOtherRule;
3057
				break;
3078
				break;
3058
			default:
3079
			default:
3059
				state = error;
3080
				state = error;
3060
			}
3081
			}
3061
		}
3082
		}
3062
	}
3083
	}
3084
3063
	switch(state) {
3085
	switch(state) {
3064
		case readyToClose :
3086
		case readyForPathOrRules:
3065
		case readyToCloseEndingWithRules :
3087
		case readyToCloseOrOtherEntry:
3066
		case readyToCloseOrOtherEntry :
3088
			Collections.reverse(currentRuleSpecs);
3067
			addNewEntry(paths, currentClasspathName, currentRuleSpecs, customEncoding, isSourceOnly);
3089
			addNewEntry(paths, currentClasspathName, currentRuleSpecs, customEncoding, isSourceOnly);
3068
			break;
3090
			break;
3069
		default :
3091
		default :
Lines 3071-3074 Link Here
3071
			this.logger.logIncorrectClasspath(currentPath);
3093
			this.logger.logIncorrectClasspath(currentPath);
3072
	}
3094
	}
3073
}
3095
}
3096
3097
private String getPath(LinkedList list, String path) {
3098
	while (!list.isEmpty()) {
3099
		if (File.pathSeparator.equalsIgnoreCase((String)list.getLast()))
3100
			break;
3101
		path = (String)list.removeLast() + path;
3102
	}
3103
	return path;
3104
}
3074
}
3105
}

Return to bug 161996