Test & fix for Bug 370271 - [compiler] NPE in PredicateGenerator with no
predicate present
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/statemachine/transformer/PredicateGenerator.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/statemachine/transformer/PredicateGenerator.java
index 8fbd64b..ec90a01 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/statemachine/transformer/PredicateGenerator.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/statemachine/transformer/PredicateGenerator.java
@@ -189,7 +189,7 @@
 		ReferenceBinding   teamType  = roleType.enclosingType();
 		TypeBinding        objParam  = scope.getJavaLangObject();
 
-		while(roleType.isRole()) { // loop up the superclass chain
+		while(roleType != null && roleType.isRole()) { // loop up the superclass chain (null if fetching super class of Confined)
 
 			char[][] methodNames = getBasePredicateNames(roleType, callinMapping);
 
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/rolesandteams/Confinement.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/rolesandteams/Confinement.java
index 6b0ba64..e297207 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/rolesandteams/Confinement.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/rolesandteams/Confinement.java
@@ -29,7 +29,7 @@
 	// Static initializer to specify tests subset using TESTS_* static variables
 	// All specified tests which does not belong to the class are skipped...
 	static {
-//		TESTS_NAMES = new String[] { "test1710_confinedBoundRole2"};
+//		TESTS_NAMES = new String[] { "test1710_confinedBoundRole3"};
 //		TESTS_NUMBERS = new int[] { 1459 };
 //		TESTS_RANGE = new int[] { 1097, -1 };
 	}
@@ -1342,6 +1342,50 @@
             "Checking Agent: OK");
     }
 
+    // a bound role is confined, callin defined
+    // see https://bugs.eclipse.org/370271 [compiler] NPE in PredicateGenerator with no predicate present
+    public void test1710_confinedBoundRole3() {
+       
+       runConformTest(
+            new String[] {
+		"T1710cbr2Main.java",
+			    "\n" +
+			    "public class T1710cbr2Main {\n" +
+			    "    public static void main(String[] args) {\n" +
+			    "        Team1710cbr2 safe = new Team1710cbr2();\n" +
+			    "        safe.activate();\n" +
+			    "        T1710cbr2 object = new T1710cbr2(\"secret\");\n" +
+			    "        object.print();\n" +
+			    "    }\n" +
+			    "}\n" +
+			    "    \n",
+		"T1710cbr2.java",
+			    "\n" +
+			    "public class T1710cbr2 {\n" +
+			    "    String name;\n" +
+			    "    T1710cbr2(String name) {\n" +
+			    "        this.name = name;\n" +
+			    "    }\n" +
+			    "    void print() {\n" +
+			    "        System.out.print(this.name);\n" +
+			    "    }\n" +
+			    "}\n" +
+			    "    \n",
+		"Team1710cbr2.java",
+			    "\n" +
+			    "public team class Team1710cbr2 {\n" +
+			    "    protected class Guard extends Confined playedBy T1710cbr2 {\n" +
+			    "        callin void forbid() {\n" +
+			    "            System.out.print(\"forbidden\");\n" +
+			    "        }\n" +
+			    "        forbid <- replace print;\n" +
+			    "    }\n" +
+			    "}\n" +
+			    "    \n"
+            },
+            "forbidden");
+    }
+
     // an array of confined is not(?) compatible
     // 1.7.11-otjld-array-of-confined-1
     public void test1711_arrayOfConfined1() {