Skip to content

Commit c93b837

Browse files
committed
Attempt to fix random java model exception errors cluttering log during test suite
Signed-off-by: Rob Stryker <[email protected]>
1 parent d002850 commit c93b837

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/CachingClassSymbolClassReader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,9 @@ public VarSymbol create(Symbol owner, CachingClassSymbolClassReader reader) {
203203
// as per https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-2.html#jvms-2.3.4
204204
o = Integer.valueOf(b.booleanValue() ? 1 : 0);
205205
} else if (TypeKind.CHAR == primitive.getKind() && o instanceof Character c) {
206-
o = Integer.valueOf((int)c.charValue());
206+
o = Integer.valueOf(c.charValue());
207207
} else if (TypeKind.BYTE == primitive.getKind() && o instanceof Byte b) {
208-
o = Integer.valueOf((int)b.byteValue());
208+
o = Integer.valueOf(b.byteValue());
209209
}
210210
}
211211
res.setData(o);

org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/JavacUtils.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ private static void configureOptions(IJavaProject javaProject, Context context,
184184
if (limitModules != null && !limitModules.isBlank()) {
185185
options.put(Option.LIMIT_MODULES, limitModules);
186186
}
187-
if (!options.isSet(Option.RELEASE) && javaProject instanceof JavaProject) {
187+
if (!options.isSet(Option.RELEASE) && javaProject instanceof JavaProject jp && jp.exists()) {
188188
try {
189189
IType systemType = javaProject.findType(Object.class.getName());
190190
if (systemType != null) {
@@ -262,7 +262,7 @@ private static void configurePaths(JavaProject javaProject, Context context, Jav
262262

263263
if (output != null) {
264264
fileManager.setLocation(StandardLocation.CLASS_OUTPUT, List.of(ensureDirExists(output)));
265-
} else if (javaProject.getProject() != null) {
265+
} else if (javaProject.getProject() != null && javaProject.getProject().exists()) {
266266
IResource member = javaProject.getProject().getParent().findMember(javaProject.getOutputLocation());
267267
if( member != null ) {
268268
File f = member.getLocation().toFile();
@@ -308,7 +308,7 @@ private static void configurePaths(JavaProject javaProject, Context context, Jav
308308
.toList());
309309
classpathEnabled = true;
310310
}
311-
if (!classpathEnabled) {
311+
if (!classpathEnabled && javaProject.exists()) {
312312
// Set<JavaProject> moduleProjects = Set.of();
313313
IClasspathEntry[] expandedClasspath = javaProject.getExpandedClasspath();
314314
Set<JavaProject> moduleProjects = Stream.of(expandedClasspath)
@@ -395,6 +395,9 @@ public static <T> boolean isEmpty(List<T> list) {
395395
private static Collection<File> classpathEntriesToFiles(JavaProject project, boolean source, Predicate<IClasspathEntry> select) {
396396
try {
397397
LinkedHashSet<File> res = new LinkedHashSet<>();
398+
if( !project.exists())
399+
return res;
400+
398401
ArrayList<IClasspathEntry> seen = new ArrayList<>();
399402
if (project.getModuleDescription() == null) {
400403
IPath outputLocation = project.getOutputLocation();
@@ -484,7 +487,7 @@ private static File ensureDirExists(File file) {
484487
}
485488

486489
public static boolean isTest(IJavaProject project, org.eclipse.jdt.internal.compiler.env.ICompilationUnit[] units) {
487-
if (units == null || project == null || project.getResource() == null) {
490+
if (units == null || project == null || project.getResource() == null || !project.exists()) {
488491
return false;
489492
}
490493
Set<IPath> testFolders = new HashSet<>();

0 commit comments

Comments
 (0)