Fix in STX:LIBJAVA source representation: cared for compilation units with no type definitions
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 31 Mar 2015 15:14:16 +0100
changeset 3435 26cdaf601d11
parent 3418 3df0a2df585e
child 3439 4d467c2fb3c5
Fix in STX:LIBJAVA source representation: cared for compilation units with no type definitions
tools/java/src/stx/libjava/tools/Source.java
--- a/tools/java/src/stx/libjava/tools/Source.java	Fri Mar 27 16:10:51 2015 +0000
+++ b/tools/java/src/stx/libjava/tools/Source.java	Tue Mar 31 15:14:16 2015 +0100
@@ -108,7 +108,12 @@
 public void setName() {
     Parser p = new Parser();
     CompilationUnitDeclaration cu = p.parse(this, true);         
-    typename = cu.types[0].name;
+    if ( cu.types != null && cu.types.length > 0 ) {
+        typename = cu.types[0].name;
+    } else {
+        typename = new char[0];
+    }
+
     if (cu.currentPackage == null) {
         // no package? 
         packagename = new char[0][0];