Skip to content

Commit

Permalink
Handled an error which could occur when reading an invalid class file.
Browse files Browse the repository at this point in the history
  • Loading branch information
neilccbrown committed Feb 27, 2024
1 parent f90e37b commit f1a0acc
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions bluej/src/main/java/bluej/parser/ParseUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ of the License, or (at your option) any later version.
import bluej.pkgmgr.Package;
import bluej.pkgmgr.target.role.Kind;
import bluej.stride.framedjava.frames.LocalCompletion;
import bluej.utility.Debug;
import threadchecker.OnThread;
import threadchecker.Tag;
import bluej.debugger.gentype.FieldReflective;
Expand Down Expand Up @@ -130,10 +131,20 @@ public static List<AssistContentThreadSafe> getLocalTypes(Package pkg, Class<?>
for(File innerClassFile : ct.getInnerClassFiles())
{
Class<?> c = pkg.getProject().loadClass(innerClassFile.getName().replaceFirst("\\.class$",""));
// If simple name is empty, it's an anonymous class, so we don't want code completions for those:
if (c != null && !c.getSimpleName().isEmpty())
try
{
nestedTypes.add(new AssistContentThreadSafe(new ImportedTypeCompletion(c, pkg.getProject().getJavadocResolver())));
// If simple name is empty, it's an anonymous class, so we don't want code completions for those:
if (c != null && !c.getSimpleName().isEmpty())
{
nestedTypes.add(new AssistContentThreadSafe(new ImportedTypeCompletion(c, pkg.getProject().getJavadocResolver())));
}
}
catch (Throwable t)
{
// It is possible that getSimpleName throws an error (which inherits from Throwable, not Exception)
// so we must guard against that. We don't need to do anything, we just won't add it as a completion.
// We may as well log the error, though:
Debug.reportError(t);
}
}
}
Expand Down

0 comments on commit f1a0acc

Please sign in to comment.