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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/core/compiler/IProblem.java (+7 lines)
Lines 1090-1095 Link Here
1090
	 */
1090
	 */
1091
	/** @since 3.1 */
1091
	/** @since 3.1 */
1092
	int CorruptedSignature = Internal + 700;
1092
	int CorruptedSignature = Internal + 700;
1093
	/**
1094
	 * Corrupted source
1095
	 */
1096
	/** @since 3.2 */
1097
	int InvalidEncoding = Internal + 701;
1098
	/** @since 3.2 */
1099
	int CannotReadSource = Internal + 702;
1093
1100
1094
	/**
1101
	/**
1095
	 * Autoboxing
1102
	 * Autoboxing
(-)compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties (+4 lines)
Lines 525-530 Link Here
525
### CORRUPTED BINARIES
525
### CORRUPTED BINARIES
526
700 = The class file {0} contains a signature ''{1}'' ill-formed at position {2}
526
700 = The class file {0} contains a signature ''{1}'' ill-formed at position {2}
527
527
528
### CORRUPTED SOURCES
529
701 = Cannot read the source from {0}; either the file uses a different encoding than {1} or it is corrupted
530
702 = Cannot read the source from {0} due to internal exception {1}
531
528
### AUTOBOXING
532
### AUTOBOXING
529
720 = The expression of type {0} is boxed into {1}
533
720 = The expression of type {0} is boxed into {1}
530
721 = The expression of type {0} is unboxed into {1}
534
721 = The expression of type {0} is unboxed into {1}
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (+32 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.problem;
11
package org.eclipse.jdt.internal.compiler.problem;
12
12
13
import java.io.CharConversionException;
14
import java.io.PrintWriter;
15
import java.io.StringWriter;
13
import java.text.MessageFormat;
16
import java.text.MessageFormat;
14
17
15
import org.eclipse.jdt.core.compiler.CategorizedProblem;
18
import org.eclipse.jdt.core.compiler.CategorizedProblem;
Lines 815-820 Link Here
815
		constructorCall.sourceStart,
818
		constructorCall.sourceStart,
816
		constructorCall.sourceEnd);
819
		constructorCall.sourceEnd);
817
}
820
}
821
public void cannotReadSource(CompilationUnitDeclaration unit, AbortCompilationUnit abortException) {
822
	String fileName = new String(unit.compilationResult.fileName);
823
	if (abortException.exception instanceof CharConversionException) {
824
		// specific encoding issue
825
		String encoding = abortException.encoding;
826
		if (encoding == null) {
827
			encoding = System.getProperty("file.encoding"); //$NON-NLS-1$
828
		}
829
		String[] arguments = new String[]{ fileName, encoding, };
830
		this.handle(
831
				IProblem.InvalidEncoding,
832
				arguments,
833
				arguments,
834
				0,
835
				0);
836
		return;
837
	}
838
	StringWriter stringWriter = new StringWriter();
839
	PrintWriter writer = new PrintWriter(stringWriter);
840
	abortException.exception.printStackTrace(writer);
841
	String exceptionTrace = stringWriter.toString();
842
	String[] arguments = new String[]{ fileName, exceptionTrace, };
843
	this.handle(
844
			IProblem.CannotReadSource,
845
			arguments,
846
			arguments,
847
			0,
848
			0);
849
}
818
public void cannotReferToNonFinalOuterLocal(LocalVariableBinding local, ASTNode location) {
850
public void cannotReferToNonFinalOuterLocal(LocalVariableBinding local, ASTNode location) {
819
	String[] arguments =new String[]{ new String(local.readableName())};
851
	String[] arguments =new String[]{ new String(local.readableName())};
820
	this.handle(
852
	this.handle(
(-)compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilationUnit.java (+12 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.problem;
11
package org.eclipse.jdt.internal.compiler.problem;
12
12
13
import java.io.IOException;
14
13
import org.eclipse.jdt.core.compiler.CategorizedProblem;
15
import org.eclipse.jdt.core.compiler.CategorizedProblem;
14
import org.eclipse.jdt.internal.compiler.CompilationResult;
16
import org.eclipse.jdt.internal.compiler.CompilationResult;
15
17
Lines 23-29 Link Here
23
25
24
	private static final long serialVersionUID = -4253893529982226734L; // backward compatible
26
	private static final long serialVersionUID = -4253893529982226734L; // backward compatible
25
	
27
	
28
	public String encoding;
29
	
26
public AbortCompilationUnit(CompilationResult compilationResult, CategorizedProblem problem) {
30
public AbortCompilationUnit(CompilationResult compilationResult, CategorizedProblem problem) {
27
	super(compilationResult, problem);
31
	super(compilationResult, problem);
28
}
32
}
33
34
/**
35
 * Used to surface encoding issues when reading sources
36
 */
37
public AbortCompilationUnit(CompilationResult compilationResult, IOException exception, String encoding) {
38
	super(compilationResult, exception);
39
	this.encoding = encoding;
40
}
29
}
41
}
(-)compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java (-10 / +18 lines)
Lines 38-43 Link Here
38
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
38
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
39
import org.eclipse.jdt.internal.compiler.parser.diagnose.DiagnoseParser;
39
import org.eclipse.jdt.internal.compiler.parser.diagnose.DiagnoseParser;
40
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
40
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
41
import org.eclipse.jdt.internal.compiler.problem.AbortCompilationUnit;
41
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
42
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
42
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
43
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
43
import org.eclipse.jdt.internal.compiler.util.Messages;
44
import org.eclipse.jdt.internal.compiler.util.Messages;
Lines 7704-7711 Link Here
7704
	try {
7705
	try {
7705
		this.diet = true;
7706
		this.diet = true;
7706
		parsedUnit = parse(sourceUnit, compilationResult);
7707
		parsedUnit = parse(sourceUnit, compilationResult);
7707
	}
7708
	} finally {
7708
	finally {
7709
		this.diet = old;
7709
		this.diet = old;
7710
	}
7710
	}
7711
	return parsedUnit;
7711
	return parsedUnit;
Lines 9033-9041 Link Here
9033
		initialize(true);
9033
		initialize(true);
9034
		goForCompilationUnit();
9034
		goForCompilationUnit();
9035
9035
9036
		/* unit creation */
9037
		this.referenceContext = 
9038
			this.compilationUnit = 
9039
				new CompilationUnitDeclaration(
9040
					this.problemReporter, 
9041
					compilationResult, 
9042
					0);
9043
9036
		/* scanners initialization */
9044
		/* scanners initialization */
9037
		char[] contents = sourceUnit.getContents();
9045
		char[] contents;
9046
		try {
9047
			contents = sourceUnit.getContents();
9048
		} catch(AbortCompilationUnit abortException) {
9049
			this.problemReporter().cannotReadSource(this.compilationUnit, abortException);
9050
			contents = CharOperation.NO_CHAR; // pretend empty from thereon
9051
		}
9038
		this.scanner.setSource(contents);
9052
		this.scanner.setSource(contents);
9053
		this.compilationUnit.sourceEnd = this.scanner.source.length - 1;
9039
		if (end != -1) this.scanner.resetTo(start, end);
9054
		if (end != -1) this.scanner.resetTo(start, end);
9040
		if (this.javadocParser != null && this.javadocParser.checkDocComment) {
9055
		if (this.javadocParser != null && this.javadocParser.checkDocComment) {
9041
			this.javadocParser.scanner.setSource(contents);
9056
			this.javadocParser.scanner.setSource(contents);
Lines 9043-9055 Link Here
9043
				this.javadocParser.scanner.resetTo(start, end);
9058
				this.javadocParser.scanner.resetTo(start, end);
9044
			}
9059
			}
9045
		}
9060
		}
9046
		/* unit creation */
9047
		this.referenceContext = 
9048
			this.compilationUnit = 
9049
				new CompilationUnitDeclaration(
9050
					this.problemReporter, 
9051
					compilationResult, 
9052
					this.scanner.source.length);
9053
		/* run automaton */
9061
		/* run automaton */
9054
		parse();
9062
		parse();
9055
	} finally {
9063
	} finally {
(-)batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java (-2 / +3 lines)
Lines 15-20 Link Here
15
15
16
import org.eclipse.jdt.core.compiler.CharOperation;
16
import org.eclipse.jdt.core.compiler.CharOperation;
17
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
17
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
18
import org.eclipse.jdt.internal.compiler.problem.AbortCompilationUnit;
18
import org.eclipse.jdt.internal.compiler.util.Util;
19
import org.eclipse.jdt.internal.compiler.util.Util;
19
20
20
public class CompilationUnit implements ICompilationUnit {
21
public class CompilationUnit implements ICompilationUnit {
Lines 56-64 Link Here
56
	try {
57
	try {
57
		return Util.getFileCharContent(new File(new String(this.fileName)), this.encoding);
58
		return Util.getFileCharContent(new File(new String(this.fileName)), this.encoding);
58
	} catch (IOException e) {
59
	} catch (IOException e) {
59
		// assume no content then
60
		this.contents = CharOperation.NO_CHAR; // assume no source if asked again
61
		throw new AbortCompilationUnit(null, e, this.encoding);
60
	}
62
	}
61
	return CharOperation.NO_CHAR;
62
}
63
}
63
/**
64
/**
64
 * @see org.eclipse.jdt.internal.compiler.env.IDependent#getFileName()
65
 * @see org.eclipse.jdt.internal.compiler.env.IDependent#getFileName()

Return to bug 130980