Skip to content

Commit 469236c

Browse files
Prevent NPE and report missing dependency instead
While generating d.ts files for the Mapbox SDK I ran into a NullPointerException I couldn't make sense of until I debugged the generator. It turned out I had to provide numerous dependencies to make it work, but I didn't want those to be part of the resulting d.ts file.. So I've now made sure the generator doesn't choke on these and logs them to the console. If the developer cares about any of those missing classes he can lookup the related dependency (library) and rerun the generator.
1 parent 6bb5ca6 commit 469236c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

dts-generator/src/main/java/com/telerik/dts/DtsApi.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,13 @@ private List<JavaClass> getInterfaces(JavaClass classInterface) {
349349
String[] interfaceNames = classInterface.getInterfaceNames();
350350
for (String intface : interfaceNames) {
351351
JavaClass clazz1 = ClassRepo.findClass(intface);
352+
353+
// Added guard to prevent NullPointerExceptions in case libs are not provided - the dev can choose to include it and rerun the generator
354+
if (clazz1 == null) {
355+
System.out.println("ignoring definitions in missing dependency: " + intface);
356+
continue;
357+
}
358+
352359
String className = clazz1.getClassName();
353360

354361
// TODO: Pete: Hardcoded until we figure out how to go around the 'type incompatible with Object' issue

0 commit comments

Comments
 (0)