Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 1 | /********************************************************************** |
| 2 | * This file is part of "Object Teams Development Tooling"-Software |
| 3 | * |
Stephan Herrmann | 273982d | 2013-01-10 22:22:03 +0100 | [diff] [blame] | 4 | * Copyright 2004, 2013 IT Service Omikron GmbH and others. |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 5 | * |
| 6 | * All rights reserved. This program and the accompanying materials |
| 7 | * are made available under the terms of the Eclipse Public License v1.0 |
| 8 | * which accompanies this distribution, and is available at |
| 9 | * http://www.eclipse.org/legal/epl-v10.html |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 10 | * |
| 11 | * Please visit http://www.eclipse.org/objectteams for updates and contact. |
| 12 | * |
| 13 | * Contributors: |
| 14 | * Thomas Dudziak - Initial API and implementation |
| 15 | * Stephan Herrmann - Initial API and implementation |
| 16 | **********************************************************************/ |
| 17 | package org.eclipse.objectteams.otdt.tests.otjld.callinbinding; |
| 18 | |
| 19 | import java.util.Map; |
| 20 | |
| 21 | import junit.framework.Test; |
| 22 | |
| 23 | import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
| 24 | import org.eclipse.objectteams.otdt.tests.otjld.AbstractOTJLDTest; |
| 25 | |
| 26 | @SuppressWarnings("unchecked") |
| 27 | public class CallinMethodBinding extends AbstractOTJLDTest { |
| 28 | |
| 29 | public CallinMethodBinding(String name) { |
| 30 | super(name); |
| 31 | } |
| 32 | |
| 33 | // Static initializer to specify tests subset using TESTS_* static variables |
| 34 | // All specified tests which does not belong to the class are skipped... |
| 35 | static { |
Stephan Herrmann | 12a2074 | 2013-04-25 20:12:57 +0200 | [diff] [blame] | 36 | // TESTS_NAMES = new String[] { "test4146_callinToConstructor" }; |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 37 | // TESTS_NUMBERS = new int[] { 1459 }; |
| 38 | // TESTS_RANGE = new int[] { 1097, -1 }; |
| 39 | } |
| 40 | |
| 41 | public static Test suite() { |
| 42 | return buildComparableTestSuite(testClass()); |
| 43 | } |
| 44 | |
| 45 | public static Class testClass() { |
| 46 | return CallinMethodBinding.class; |
| 47 | } |
| 48 | |
| 49 | // a role method is callin-bound as 'before' to a method in the direct base class |
| 50 | // 4.1.1-otjld-before-callin-binding-1 |
| 51 | public void test411_beforeCallinBinding1() { |
| 52 | |
| 53 | runConformTest( |
| 54 | new String[] { |
| 55 | "T411bcb1Main.java", |
| 56 | "\n" + |
| 57 | "public class T411bcb1Main {\n" + |
| 58 | " public static void main(String[] args) {\n" + |
| 59 | " Team411bcb1 t = new Team411bcb1();\n" + |
| 60 | "\n" + |
| 61 | " t.activate();\n" + |
| 62 | "\n" + |
| 63 | " T411bcb1_2 o = new T411bcb1_2();\n" + |
| 64 | "\n" + |
| 65 | " System.out.print(o.getValue(2));\n" + |
| 66 | " }\n" + |
| 67 | "}\n" + |
| 68 | " \n", |
| 69 | "T411bcb1_1.java", |
| 70 | "\n" + |
| 71 | "public class T411bcb1_1 {\n" + |
| 72 | " private static int value = 0;\n" + |
| 73 | " public static void setValue(int arg) {\n" + |
| 74 | " value = 1;\n" + |
| 75 | " }\n" + |
| 76 | " public static int getValue() {\n" + |
| 77 | " return value;\n" + |
| 78 | " }\n" + |
| 79 | "}\n" + |
| 80 | " \n", |
| 81 | "T411bcb1_2.java", |
| 82 | "\n" + |
| 83 | "public class T411bcb1_2 {\n" + |
| 84 | " public int getValue(int arg) {\n" + |
| 85 | " return T411bcb1_1.getValue();\n" + |
| 86 | " }\n" + |
| 87 | "}\n" + |
| 88 | " \n", |
| 89 | "Team411bcb1.java", |
| 90 | "\n" + |
| 91 | "public team class Team411bcb1 {\n" + |
| 92 | " public class Role411bcb1 extends T411bcb1_1 playedBy T411bcb1_2 {\n" + |
| 93 | " setValue <- before getValue;\n" + |
| 94 | " }\n" + |
| 95 | "}\n" + |
| 96 | " \n" |
| 97 | }, |
| 98 | "1"); |
| 99 | } |
| 100 | |
| 101 | // a role method is callin-bound as 'after' to a method in the base class of the implicit superrole |
| 102 | // 4.1.1-otjld-before-callin-binding-2 |
| 103 | public void test411_beforeCallinBinding2() { |
| 104 | |
| 105 | runConformTest( |
| 106 | new String[] { |
| 107 | "T411bcb2Main.java", |
| 108 | "\n" + |
| 109 | "public class T411bcb2Main {\n" + |
| 110 | " public static void main(String[] args) {\n" + |
| 111 | " Team411bcb2_2 t = new Team411bcb2_2();\n" + |
| 112 | "\n" + |
| 113 | " t.activate();\n" + |
| 114 | "\n" + |
| 115 | " T411bcb2_2 o = new T411bcb2_2();\n" + |
| 116 | "\n" + |
| 117 | " System.out.print(o.getValue(\"OK\")+\"|\"+t.getValue());\n" + |
| 118 | " }\n" + |
| 119 | "}\n" + |
| 120 | " \n", |
| 121 | "T411bcb2_1.java", |
| 122 | "\n" + |
| 123 | "public class T411bcb2_1 {\n" + |
| 124 | " String getValue(String arg) {\n" + |
| 125 | " return arg;\n" + |
| 126 | " }\n" + |
| 127 | "}\n" + |
| 128 | " \n", |
| 129 | "T411bcb2_2.java", |
| 130 | "\n" + |
| 131 | "public class T411bcb2_2 extends T411bcb2_1 {}\n" + |
| 132 | " \n", |
| 133 | "Team411bcb2_1.java", |
| 134 | "\n" + |
| 135 | "public team class Team411bcb2_1 {\n" + |
| 136 | " private String value = \"NOTOK\";\n" + |
| 137 | "\n" + |
| 138 | " public class Role411bcb2 playedBy T411bcb2_2 {\n" + |
| 139 | " protected void setValueInternal(String arg) {\n" + |
| 140 | " Team411bcb2_1.this.value = arg;\n" + |
| 141 | " }\n" + |
| 142 | " }\n" + |
| 143 | "\n" + |
| 144 | " public String getValue() {\n" + |
| 145 | " return value;\n" + |
| 146 | " }\n" + |
| 147 | "}\n" + |
| 148 | " \n", |
| 149 | "Team411bcb2_2.java", |
| 150 | "\n" + |
| 151 | "public team class Team411bcb2_2 extends Team411bcb2_1 {\n" + |
| 152 | " public class Role411bcb2 {\n" + |
| 153 | " setValueInternal <- after getValue;\n" + |
| 154 | " }\n" + |
| 155 | "}\n" + |
| 156 | " \n" |
| 157 | }, |
| 158 | "OK|OK"); |
| 159 | } |
| 160 | |
| 161 | // a role method is callin-bound as 'replace' to a method in the base class of the explicit superrole |
| 162 | // 4.1.1-otjld-before-callin-binding-3 |
| 163 | public void test411_beforeCallinBinding3() { |
| 164 | |
| 165 | runConformTest( |
| 166 | new String[] { |
| 167 | "T411bcb3Main.java", |
| 168 | "\n" + |
| 169 | "public class T411bcb3Main {\n" + |
| 170 | " public static void main(String[] args) {\n" + |
| 171 | " Team411bcb3 t = new Team411bcb3();\n" + |
| 172 | "\n" + |
| 173 | " t.activate();\n" + |
| 174 | "\n" + |
| 175 | " T411bcb3 o = new T411bcb3();\n" + |
| 176 | "\n" + |
| 177 | " System.out.print(o.getValue(\"NOTOK\")+\"|\"+t.getValue());\n" + |
| 178 | " }\n" + |
| 179 | "}\n" + |
| 180 | " \n", |
| 181 | "T411bcb3.java", |
| 182 | "\n" + |
| 183 | "public class T411bcb3 {\n" + |
| 184 | " public String getValue(String arg) {\n" + |
| 185 | " return arg;\n" + |
| 186 | " }\n" + |
| 187 | "}\n" + |
| 188 | " \n", |
| 189 | "Team411bcb3.java", |
| 190 | "\n" + |
| 191 | "public team class Team411bcb3 {\n" + |
| 192 | " private String value = \"NOTOK\";\n" + |
| 193 | "\n" + |
| 194 | " public class Role411bcb3_1 playedBy T411bcb3 {\n" + |
| 195 | " callin String test() {\n" + |
| 196 | " base.test();\n" + |
| 197 | " Team411bcb3.this.value = \"OK\";\n" + |
| 198 | " return \"OK\";\n" + |
| 199 | " }\n" + |
| 200 | " }\n" + |
| 201 | "\n" + |
| 202 | " public class Role411bcb3_2 extends Role411bcb3_1 {\n" + |
| 203 | " String test() <- replace String getValue(String arg);\n" + |
| 204 | " }\n" + |
| 205 | "\n" + |
| 206 | " public String getValue() {\n" + |
| 207 | " return value;\n" + |
| 208 | " }\n" + |
| 209 | "}\n" + |
| 210 | " \n" |
| 211 | }, |
| 212 | "OK|OK"); |
| 213 | } |
| 214 | |
| 215 | // a replace binding mentions a buggy callin method |
| 216 | // 4.1.1-otjld-before-callin-binding-3f |
| 217 | public void test411_beforeCallinBinding3f() { |
| 218 | |
| 219 | runNegativeTest( |
| 220 | new String[] { |
| 221 | "p1/T411bcb3f.java", |
| 222 | "\n" + |
| 223 | "package p1;\n" + |
| 224 | "public class T411bcb3f {\n" + |
| 225 | " public void foo() {\n" + |
| 226 | " }\n" + |
| 227 | "}\n" + |
| 228 | " \n", |
| 229 | "p1/Team411bcb3f_1.java", |
| 230 | "\n" + |
| 231 | "package p1;\n" + |
| 232 | "public team class Team411bcb3f_1 {\n" + |
| 233 | " protected R r;\n" + |
| 234 | " protected class R playedBy T411bcb3f {\n" + |
| 235 | " callin void broken () {\n" + |
| 236 | " base.broken();\n" + |
| 237 | " }\n" + |
| 238 | " }\n" + |
| 239 | "}\n" + |
| 240 | " \n", |
| 241 | "p2/Team411bcb3f_2.java", |
| 242 | "\n" + |
| 243 | "package p2;\n" + |
| 244 | "import p1.Team411bcb3f_1;\n" + |
| 245 | "public team class Team411bcb3f_2 extends Team411bcb3f_1 {\n" + |
| 246 | " @Override\n" + |
| 247 | " public class R {\n" + |
| 248 | " public R() { base(); }\n" + |
| 249 | " public void blub() { }\n" + |
| 250 | " @Override\n" + |
| 251 | " callin void broken () {\n" + |
| 252 | " Team411bcb3f_1.this.r= this;\n" + |
| 253 | " base.broken();\n" + |
| 254 | " Team411bcb3f_1.this.r= null;\n" + |
| 255 | " }\n" + |
| 256 | " broken <- replace foo;\n" + |
| 257 | " }\n" + |
| 258 | "}\n", |
| 259 | }, |
| 260 | "----------\n" + |
| 261 | "1. ERROR in p2\\Team411bcb3f_2.java (at line 11)\n" + |
| 262 | " Team411bcb3f_1.this.r= this;\n" + |
| 263 | " ^^^^^^^^^^^^^^^^^^^\n" + |
| 264 | "No enclosing instance of the type Team411bcb3f_1 is accessible in scope\n" + |
| 265 | "----------\n" + |
| 266 | "2. ERROR in p2\\Team411bcb3f_2.java (at line 11)\n" + |
| 267 | " Team411bcb3f_1.this.r= this;\n" + |
| 268 | " ^\n" + |
| 269 | "The field Team411bcb3f_1.r is not visible\n" + |
| 270 | "----------\n" + |
| 271 | "3. ERROR in p2\\Team411bcb3f_2.java (at line 13)\n" + |
| 272 | " Team411bcb3f_1.this.r= null;\n" + |
| 273 | " ^^^^^^^^^^^^^^^^^^^\n" + |
| 274 | "No enclosing instance of the type Team411bcb3f_1 is accessible in scope\n" + |
| 275 | "----------\n" + |
| 276 | "4. ERROR in p2\\Team411bcb3f_2.java (at line 13)\n" + |
| 277 | " Team411bcb3f_1.this.r= null;\n" + |
| 278 | " ^\n" + |
| 279 | "The field Team411bcb3f_1.r is not visible\n" + |
| 280 | "----------\n", |
| 281 | null/*classLibraries*/, |
| 282 | true/*shouldFlushOutputDirectory*/, |
| 283 | null/*customOptions*/, |
| 284 | true/*generateOutput*/, |
| 285 | false/*showCategory*/, |
| 286 | false); |
| 287 | runConformTest( |
| 288 | new String[] { |
| 289 | "T411bcb3f_2.java", |
| 290 | "import p2.Team411bcb3f_2;\n" + |
| 291 | "public class T411bcb3f_2 {\n" + |
| 292 | " final Team411bcb3f_2 t= new Team411bcb3f_2();\n" + |
| 293 | " R<@t> r= t.new R();\n" + |
| 294 | " void bar() {\n" + |
| 295 | " r.blub();\n" + |
| 296 | " }\n" + |
| 297 | "}\n" + |
| 298 | " \n" |
| 299 | }, |
| 300 | null/*expectedOutput*/, |
| 301 | null/*classLibraries*/, |
| 302 | false/*shouldFlushOutputDirectory*/, |
| 303 | null/*vmArguments*/); |
| 304 | } |
| 305 | |
| 306 | // a role method is callin-bound as 'replace' to a method in the base class of a remote superrole |
| 307 | // 4.1.1-otjld-before-callin-binding-4 |
| 308 | public void test411_beforeCallinBinding4() { |
| 309 | |
| 310 | runConformTest( |
| 311 | new String[] { |
| 312 | "T411bcb4Main.java", |
| 313 | "\n" + |
| 314 | "public class T411bcb4Main {\n" + |
| 315 | " public static void main(String[] args) {\n" + |
| 316 | " Team411bcb4_2 t = new Team411bcb4_2();\n" + |
| 317 | "\n" + |
| 318 | " t.activate();\n" + |
| 319 | "\n" + |
| 320 | " T411bcb4_2 o = new T411bcb4_2();\n" + |
| 321 | "\n" + |
| 322 | " System.out.print(o.getValue(\"4\", \"5\")+\"|\"+t.getValue());\n" + |
| 323 | " }\n" + |
| 324 | "}\n" + |
| 325 | " \n", |
| 326 | "T411bcb4_1.java", |
| 327 | "\n" + |
| 328 | "public class T411bcb4_1 {\n" + |
| 329 | " protected String getValue(String arg1, String arg2) {\n" + |
| 330 | " return \"1\";\n" + |
| 331 | " }\n" + |
| 332 | "}\n" + |
| 333 | " \n", |
| 334 | "T411bcb4_2.java", |
| 335 | "\n" + |
| 336 | "public class T411bcb4_2 extends T411bcb4_1 {}\n" + |
| 337 | " \n", |
| 338 | "Team411bcb4_1.java", |
| 339 | "\n" + |
| 340 | "public team class Team411bcb4_1 {\n" + |
| 341 | " private String value = \"2\";\n" + |
| 342 | "\n" + |
| 343 | " public class Role411bcb4_1 playedBy T411bcb4_1 {\n" + |
| 344 | " callin String test(String arg) {\n" + |
| 345 | " Team411bcb4_1.this.setValue(\"3\");\n" + |
| 346 | " return base.test(arg);\n" + |
| 347 | " }\n" + |
| 348 | " }\n" + |
| 349 | "\n" + |
| 350 | " protected void setValue(String value) {\n" + |
| 351 | " this.value = value;\n" + |
| 352 | " }\n" + |
| 353 | "\n" + |
| 354 | " public String getValue() {\n" + |
| 355 | " return value;\n" + |
| 356 | " }\n" + |
| 357 | "}\n" + |
| 358 | " \n", |
| 359 | "Team411bcb4_2.java", |
| 360 | "\n" + |
| 361 | "public team class Team411bcb4_2 extends Team411bcb4_1 {\n" + |
| 362 | "\n" + |
| 363 | " public class Role411bcb4_2 extends Role411bcb4_1 playedBy T411bcb4_2 {\n" + |
| 364 | " String test(String arg) <- replace String getValue(String arg1, String arg2) with {\n" + |
| 365 | " arg <- arg2,\n" + |
| 366 | " result -> result\n" + |
| 367 | " }\n" + |
| 368 | " }\n" + |
| 369 | "}\n" + |
| 370 | " \n" |
| 371 | }, |
| 372 | "1|3"); |
| 373 | } |
| 374 | |
| 375 | // a role method is callin-bound as 'replace' to a method in the base class of a remote superrole |
| 376 | // 4.1.1-otjld-before-callin-binding-5 |
| 377 | public void test411_beforeCallinBinding5() { |
| 378 | |
| 379 | runConformTest( |
| 380 | new String[] { |
| 381 | "T411bcb5Main.java", |
| 382 | "\n" + |
| 383 | "public class T411bcb5Main {\n" + |
| 384 | " public static void main(String[] args) {\n" + |
| 385 | " Team411bcb5_2 t = new Team411bcb5_2();\n" + |
| 386 | "\n" + |
| 387 | " t.activate();\n" + |
| 388 | "\n" + |
| 389 | " T411bcb5_2 o = new T411bcb5_2();\n" + |
| 390 | "\n" + |
| 391 | " System.out.print(o.getValue(\"1\", \"2\")+\"|\"+t.getValue());\n" + |
| 392 | " }\n" + |
| 393 | "}\n" + |
| 394 | " \n", |
| 395 | "T411bcb5_1.java", |
| 396 | "\n" + |
| 397 | "public class T411bcb5_1 {\n" + |
| 398 | " protected String getValue(String arg1, String arg2) {\n" + |
| 399 | " return arg1+arg2;\n" + |
| 400 | " }\n" + |
| 401 | "}\n" + |
| 402 | " \n", |
| 403 | "T411bcb5_2.java", |
| 404 | "\n" + |
| 405 | "public class T411bcb5_2 extends T411bcb5_1 {}\n" + |
| 406 | " \n", |
| 407 | "Team411bcb5_1.java", |
| 408 | "\n" + |
| 409 | "public team class Team411bcb5_1 {\n" + |
| 410 | " private String value = \"NOTOK\";\n" + |
| 411 | "\n" + |
| 412 | " public class Role411bcb5_1 playedBy T411bcb5_1 {\n" + |
| 413 | " callin String test(String arg) {\n" + |
| 414 | " Team411bcb5_1.this.setValue(arg);\n" + |
| 415 | " return base.test(\"3\")+\"4\";\n" + |
| 416 | " }\n" + |
| 417 | " }\n" + |
| 418 | "\n" + |
| 419 | " protected void setValue(String value) {\n" + |
| 420 | " this.value = value;\n" + |
| 421 | " }\n" + |
| 422 | "\n" + |
| 423 | " public String getValue() {\n" + |
| 424 | " return value;\n" + |
| 425 | " }\n" + |
| 426 | "}\n" + |
| 427 | " \n", |
| 428 | "Team411bcb5_2.java", |
| 429 | "\n" + |
| 430 | "public team class Team411bcb5_2 extends Team411bcb5_1 {\n" + |
| 431 | "\n" + |
| 432 | " public class Role411bcb5_2 extends Role411bcb5_1 playedBy T411bcb5_2 {\n" + |
| 433 | " String test(String arg) <- replace String getValue(String arg1, String arg2) with {\n" + |
| 434 | " arg <- arg2,\n" + |
| 435 | " result -> result\n" + |
| 436 | " }\n" + |
| 437 | " }\n" + |
| 438 | "}\n" + |
| 439 | " \n" |
| 440 | }, |
| 441 | "134|2"); |
| 442 | } |
| 443 | |
| 444 | // non simple expression in replace param mapping |
| 445 | // 4.1.1-otjld-before-callin-binding-6 |
| 446 | public void test411_beforeCallinBinding6() { |
| 447 | runNegativeTest( |
| 448 | new String[] { |
| 449 | "T411bcb6_1.java", |
| 450 | "\n" + |
| 451 | "public class T411bcb6_1 {\n" + |
| 452 | " protected String getValue(String arg1, String arg2) {\n" + |
| 453 | " return \"NOTOK\";\n" + |
| 454 | " }\n" + |
| 455 | "}\n" + |
| 456 | " \n", |
| 457 | "T411bcb6_2.java", |
| 458 | "\n" + |
| 459 | "public class T411bcb6_2 extends T411bcb6_1 {}\n" + |
| 460 | " \n", |
| 461 | "Team411bcb6_1.java", |
| 462 | "\n" + |
| 463 | "public team class Team411bcb6_1 {\n" + |
| 464 | " private String value = \"NOTOK\";\n" + |
| 465 | "\n" + |
| 466 | " public class Role411bcb6_1 playedBy T411bcb6_1 {\n" + |
| 467 | " callin String test(String arg) {\n" + |
| 468 | " Team411bcb6_1.this.setValue(\"OK\");\n" + |
| 469 | " return base.test(arg);\n" + |
| 470 | " }\n" + |
| 471 | " }\n" + |
| 472 | "\n" + |
| 473 | " protected void setValue(String value) {\n" + |
| 474 | " this.value = value;\n" + |
| 475 | " }\n" + |
| 476 | "\n" + |
| 477 | " public String getValue() {\n" + |
| 478 | " return value;\n" + |
| 479 | " }\n" + |
| 480 | "}\n" + |
| 481 | " \n", |
| 482 | "Team411bcb6_2.java", |
| 483 | "\n" + |
| 484 | "public team class Team411bcb6_2 extends Team411bcb6_1 {\n" + |
| 485 | "\n" + |
| 486 | " public class Role411bcb6_2 extends Role411bcb6_1 playedBy T411bcb6_2 {\n" + |
| 487 | " String test(String arg) <- replace String getValue(String arg1, String arg2) with {\n" + |
| 488 | " arg <- arg2+\"X\",\n" + |
| 489 | " result -> result\n" + |
| 490 | " }\n" + |
| 491 | " }\n" + |
| 492 | "}\n" + |
| 493 | " \n" |
| 494 | }, |
| 495 | null); |
| 496 | } |
| 497 | |
| 498 | // a callin binding has a signature without parameter names |
| 499 | // 4.1.2-otjld-callin-binding-without-parameter-names-1 |
| 500 | public void test412_callinBindingWithoutParameterNames1() { |
| 501 | runNegativeTest( |
| 502 | new String[] { |
| 503 | "T412cbwpn1.java", |
| 504 | "\n" + |
| 505 | "public class T412cbwpn1 {\n" + |
| 506 | " public String getValue(String arg) {\n" + |
| 507 | " return arg;\n" + |
| 508 | " }\n" + |
| 509 | "}\n" + |
| 510 | " \n", |
| 511 | "Team412cbwpn1.java", |
| 512 | "\n" + |
| 513 | "public team class Team412cbwpn1 {\n" + |
| 514 | "\n" + |
| 515 | " public class Role412cbwpn1 playedBy T412cbwpn1 {\n" + |
| 516 | " callin String getValue(String arg) {\n" + |
| 517 | " return base.getValue(arg);\n" + |
| 518 | " }\n" + |
| 519 | " String getValue(String) <- replace String getValue(String arg);\n" + |
| 520 | " }\n" + |
| 521 | "}\n" + |
| 522 | " \n" |
| 523 | }, |
| 524 | null); |
| 525 | } |
| 526 | |
| 527 | // a callin binding has a signature without parameter names |
| 528 | // 4.1.2-otjld-callin-binding-without-parameter-names-2 |
| 529 | public void test412_callinBindingWithoutParameterNames2() { |
| 530 | runNegativeTest( |
| 531 | new String[] { |
| 532 | "T412cbwpn2.java", |
| 533 | "\n" + |
| 534 | "public class T412cbwpn2 {\n" + |
| 535 | " public String getValue(String arg) {\n" + |
| 536 | " return arg;\n" + |
| 537 | " }\n" + |
| 538 | "}\n" + |
| 539 | " \n", |
| 540 | "Team412cbwpn2.java", |
| 541 | "\n" + |
| 542 | "public team class Team412cbwpn2 {\n" + |
| 543 | "\n" + |
| 544 | " public class Role412cbwpn2 playedBy T412cbwpn2 {\n" + |
| 545 | " public String getValue(String arg) {\n" + |
| 546 | " return arg;\n" + |
| 547 | " }\n" + |
| 548 | " String getValue(String arg) <- after String getValue(String);\n" + |
| 549 | " }\n" + |
| 550 | "}\n" + |
| 551 | " \n" |
| 552 | }, |
| 553 | null); |
| 554 | } |
| 555 | |
| 556 | // a role method is callin-bound as 'replace' and overwrites a replace callin-binding in the superrole, named callin |
| 557 | // 4.1.3-otjld-overwriting-inherited-callin-binding-1 |
| 558 | public void test413_overwritingInheritedCallinBinding1() { |
| 559 | |
| 560 | runConformTest( |
| 561 | new String[] { |
| 562 | "T413oicb1Main.java", |
| 563 | "\n" + |
| 564 | "public class T413oicb1Main {\n" + |
| 565 | " public static void main(String[] args) {\n" + |
| 566 | " Team413oicb1_2 t = new Team413oicb1_2();\n" + |
| 567 | "\n" + |
| 568 | " within (t) {\n" + |
| 569 | " T413oicb1 o = new T413oicb1();\n" + |
| 570 | "\n" + |
| 571 | " System.out.print(o.getValue());\n" + |
| 572 | " }\n" + |
| 573 | " }\n" + |
| 574 | "}\n" + |
| 575 | " \n", |
| 576 | "T413oicb1.java", |
| 577 | "\n" + |
| 578 | "public class T413oicb1 {\n" + |
| 579 | " public String getValue() {\n" + |
| 580 | " return \"NOTOK\";\n" + |
| 581 | " }\n" + |
| 582 | "}\n" + |
| 583 | " \n", |
| 584 | "Team413oicb1_1.java", |
| 585 | "\n" + |
| 586 | "public team class Team413oicb1_1 {\n" + |
| 587 | " public class Role413oicb1 playedBy T413oicb1 {\n" + |
| 588 | " callin String test() {\n" + |
| 589 | " base.test();\n" + |
| 590 | " return \"NOTOK\";\n" + |
| 591 | " }\n" + |
| 592 | " testGetValue:\n" + |
| 593 | " test <- replace getValue;\n" + |
| 594 | " }\n" + |
| 595 | "}\n" + |
| 596 | " \n", |
| 597 | "Team413oicb1_2.java", |
| 598 | "\n" + |
| 599 | "public team class Team413oicb1_2 extends Team413oicb1_1 {\n" + |
| 600 | " public class Role413oicb1 {\n" + |
| 601 | " callin String test2() {\n" + |
| 602 | " base.test2();\n" + |
| 603 | " return \"OK\";\n" + |
| 604 | " }\n" + |
| 605 | " testGetValue:\n" + |
| 606 | " String test2() <- replace String getValue();\n" + |
| 607 | " }\n" + |
| 608 | "}\n" + |
| 609 | " \n" |
| 610 | }, |
| 611 | "OK"); |
| 612 | } |
| 613 | |
| 614 | // a role method is callin-bound as 'replace' and adds to a replace callin-binding in the superrole, precedence used |
| 615 | // 4.1.3-otjld-overwriting-inherited-callin-binding-1a |
| 616 | public void test413_overwritingInheritedCallinBinding1a() { |
| 617 | |
| 618 | runConformTest( |
| 619 | new String[] { |
| 620 | "T413oicb1aMain.java", |
| 621 | "\n" + |
| 622 | "public class T413oicb1aMain {\n" + |
| 623 | " public static void main(String[] args) {\n" + |
| 624 | " Team413oicb1a_2 t = new Team413oicb1a_2();\n" + |
| 625 | "\n" + |
| 626 | " within (t) {\n" + |
| 627 | " T413oicb1a o = new T413oicb1a();\n" + |
| 628 | "\n" + |
| 629 | " System.out.print(o.getValue());\n" + |
| 630 | " }\n" + |
| 631 | " }\n" + |
| 632 | "}\n" + |
| 633 | " \n", |
| 634 | "T413oicb1a.java", |
| 635 | "\n" + |
| 636 | "public class T413oicb1a {\n" + |
| 637 | " public String getValue() {\n" + |
| 638 | " return \"O\";\n" + |
| 639 | " }\n" + |
| 640 | "}\n" + |
| 641 | " \n", |
| 642 | "Team413oicb1a_1.java", |
| 643 | "\n" + |
| 644 | "public team class Team413oicb1a_1 {\n" + |
| 645 | " public class Role413oicb1a playedBy T413oicb1a {\n" + |
| 646 | " callin String test() {\n" + |
| 647 | " return base.test()+\"!\";\n" + |
| 648 | " }\n" + |
| 649 | " testGetValue:\n" + |
| 650 | " test <- replace getValue;\n" + |
| 651 | " }\n" + |
| 652 | "}\n" + |
| 653 | " \n", |
| 654 | "Team413oicb1a_2.java", |
| 655 | "\n" + |
| 656 | "public team class Team413oicb1a_2 extends Team413oicb1a_1 {\n" + |
| 657 | " public class Role413oicb1a {\n" + |
| 658 | " callin String test2() {\n" + |
| 659 | " return base.test2()+\"K\";\n" + |
| 660 | " }\n" + |
| 661 | " test2GetValue:\n" + |
| 662 | " String test2() <- replace String getValue();\n" + |
| 663 | " }\n" + |
| 664 | " precedence Role413oicb1a.testGetValue, Role413oicb1a.test2GetValue;\n" + |
| 665 | "}\n" + |
| 666 | " \n" |
| 667 | }, |
| 668 | "OK!"); |
| 669 | } |
| 670 | |
| 671 | // a role method is callin-bound as 'replace' and overwrites a replace callin-binding in the superrole, callins have no name |
| 672 | // 4.1.3-otjld-overwriting-inherited-callin-binding-1f |
| 673 | public void test413_overwritingInheritedCallinBinding1f() { |
| 674 | runNegativeTestMatching( |
| 675 | new String[] { |
| 676 | "Team413oicb1f_2.java", |
| 677 | "\n" + |
| 678 | "public team class Team413oicb1f_2 extends Team413oicb1f_1 {\n" + |
| 679 | " public class Role413oicb1f {\n" + |
| 680 | " callin String test2() {\n" + |
| 681 | " base.test2();\n" + |
| 682 | " return \"OK\";\n" + |
| 683 | " }\n" + |
| 684 | " String test2() <- replace String getValue();\n" + |
| 685 | " }\n" + |
| 686 | "}\n" + |
| 687 | " \n", |
| 688 | "T413oicb1f.java", |
| 689 | "\n" + |
| 690 | "public class T413oicb1f {\n" + |
| 691 | " public String getValue() {\n" + |
| 692 | " return \"NOTOK\";\n" + |
| 693 | " }\n" + |
| 694 | "}\n" + |
| 695 | " \n", |
| 696 | "Team413oicb1f_1.java", |
| 697 | "\n" + |
| 698 | "public team class Team413oicb1f_1 {\n" + |
| 699 | " public class Role413oicb1f playedBy T413oicb1f {\n" + |
| 700 | " callin String test() {\n" + |
| 701 | " base.test();\n" + |
| 702 | " return \"NOTOK\";\n" + |
| 703 | " }\n" + |
| 704 | " test <- replace getValue;\n" + |
| 705 | " }\n" + |
| 706 | "}\n" + |
| 707 | " \n" |
| 708 | }, |
| 709 | "OTJLD 4.8"); |
| 710 | } |
| 711 | |
| 712 | // named callin bindings in two _independent_ roles, precedence missing |
| 713 | // 4.1.3-otjld-overwriting-inherited-callin-binding-1g |
| 714 | public void test413_overwritingInheritedCallinBinding1g() { |
| 715 | runNegativeTestMatching( |
| 716 | new String[] { |
| 717 | "Team413oicb1g_2.java", |
| 718 | "\n" + |
| 719 | "public team class Team413oicb1g_2 extends Team413oicb1g_1 {\n" + |
| 720 | " public class Role413oicb1g_2 playedBy T413oicb1g {\n" + |
| 721 | " callin String test2() {\n" + |
| 722 | " return base.test2()+\"K\";\n" + |
| 723 | " }\n" + |
| 724 | " testGetValue:\n" + |
| 725 | " String test2() <- replace String getValue();\n" + |
| 726 | " }\n" + |
| 727 | "}\n" + |
| 728 | " \n", |
| 729 | "T413oicb1g.java", |
| 730 | "\n" + |
| 731 | "public class T413oicb1g {\n" + |
| 732 | " public String getValue() {\n" + |
| 733 | " return \"O\";\n" + |
| 734 | " }\n" + |
| 735 | "}\n" + |
| 736 | " \n", |
| 737 | "Team413oicb1g_1.java", |
| 738 | "\n" + |
| 739 | "public team class Team413oicb1g_1 {\n" + |
| 740 | " public class Role413oicb1g_1 playedBy T413oicb1g {\n" + |
| 741 | " callin String test() {\n" + |
| 742 | " return base.test()+\"!\";\n" + |
| 743 | " }\n" + |
| 744 | " testGetValue:\n" + |
| 745 | " test <- replace getValue;\n" + |
| 746 | " }\n" + |
| 747 | "}\n" + |
| 748 | " \n" |
| 749 | }, |
| 750 | "4.8"); |
| 751 | } |
| 752 | |
| 753 | // named callin bindings in two _independent_ roles, precedence missing, re-use purely copied binary role |
| 754 | // 4.1.3-otjld-overwriting-inherited-callin-binding-1h |
| 755 | public void test413_overwritingInheritedCallinBinding1h() { |
| 756 | runNegativeTestMatching( |
| 757 | new String[] { |
| 758 | "Team413oicb1h_2.java", |
| 759 | "\n" + |
| 760 | "public team class Team413oicb1h_2 extends Team413oicb1h_1 {\n" + |
| 761 | " public class Role413oicb1h_2 playedBy T413oicb1h {\n" + |
| 762 | " callin String test2() {\n" + |
| 763 | " return base.test2()+\"K\";\n" + |
| 764 | " }\n" + |
| 765 | " testGetValue:\n" + |
| 766 | " String test2() <- replace String getValue();\n" + |
| 767 | " }\n" + |
| 768 | "}\n" + |
| 769 | " \n", |
| 770 | "T413oicb1h.java", |
| 771 | "\n" + |
| 772 | "public class T413oicb1h {\n" + |
| 773 | " public String getValue() {\n" + |
| 774 | " return \"O\";\n" + |
| 775 | " }\n" + |
| 776 | "}\n" + |
| 777 | " \n", |
| 778 | "Team413oicb1h_1.java", |
| 779 | "\n" + |
| 780 | "public team class Team413oicb1h_1 {\n" + |
| 781 | " public class Role413oicb1h_1 playedBy T413oicb1h {\n" + |
| 782 | " callin String test() {\n" + |
| 783 | " return base.test()+\"!\";\n" + |
| 784 | " }\n" + |
| 785 | " testGetValue:\n" + |
| 786 | " test <- replace getValue;\n" + |
| 787 | " }\n" + |
| 788 | "}\n" + |
| 789 | " \n" |
| 790 | }, |
| 791 | "4.8"); |
| 792 | } |
| 793 | |
| 794 | // a role method is callin-bound as 'replace' and overwrites a name replace callin-binding in the superrole, |
| 795 | // NOTE: mapping overriding along 'extends' is not yet defined. |
| 796 | // Is problematic because both bindings will exist within the same team! |
| 797 | // 4.1.3-otjld-overwriting-inherited-callin-binding-2 |
| 798 | public void test413_overwritingInheritedCallinBinding2() { |
| 799 | |
| 800 | runConformTest( |
| 801 | new String[] { |
| 802 | "T413oicb2Main.java", |
| 803 | "\n" + |
| 804 | "public class T413oicb2Main {\n" + |
| 805 | " public static void main(String[] args) {\n" + |
| 806 | " Team413oicb2 t = new Team413oicb2();\n" + |
| 807 | "\n" + |
| 808 | " within (t) {\n" + |
| 809 | " T413oicb2_2 o = new T413oicb2_2();\n" + |
| 810 | "\n" + |
| 811 | " System.out.print(o.getValue());\n" + |
| 812 | " }\n" + |
| 813 | " }\n" + |
| 814 | "}\n" + |
| 815 | " \n", |
| 816 | "T413oicb2_1.java", |
| 817 | "\n" + |
| 818 | "public class T413oicb2_1 {\n" + |
| 819 | " public String getValue() {\n" + |
| 820 | " return \"NOTOK\";\n" + |
| 821 | " }\n" + |
| 822 | "}\n" + |
| 823 | " \n", |
| 824 | "T413oicb2_2.java", |
| 825 | "\n" + |
| 826 | "public class T413oicb2_2 extends T413oicb2_1 {}\n" + |
| 827 | " \n", |
| 828 | "Team413oicb2.java", |
| 829 | "\n" + |
| 830 | "public team class Team413oicb2 {\n" + |
| 831 | " public class Role413oicb2_1 playedBy T413oicb2_1 {\n" + |
| 832 | " callin String test() {\n" + |
| 833 | " base.test();\n" + |
| 834 | " return \"NOTOK\";\n" + |
| 835 | " }\n" + |
| 836 | " testGetValue:\n" + |
| 837 | " String test() <- replace String getValue();\n" + |
| 838 | " }\n" + |
| 839 | "\n" + |
| 840 | " public class Role413oicb2_2 extends Role413oicb2_1 playedBy T413oicb2_2 {\n" + |
| 841 | " callin String test() {\n" + |
| 842 | " base.test();\n" + |
| 843 | " return \"OK\";\n" + |
| 844 | " }\n" + |
| 845 | " testGetValue:\n" + |
| 846 | " test <- replace getValue;\n" + |
| 847 | " }\n" + |
| 848 | "}\n" + |
| 849 | " \n" |
| 850 | }, |
| 851 | "OK"); |
| 852 | } |
| 853 | |
| 854 | // a role method is callin-bound as 'replace' and overwrites a replace callin-binding in the superrole |
| 855 | // 4.1.3-otjld-overwriting-inherited-callin-binding-2f |
| 856 | public void test413_overwritingInheritedCallinBinding2f() { |
| 857 | runNegativeTestMatching( |
| 858 | new String[] { |
| 859 | "Team413oicb2f.java", |
| 860 | "\n" + |
| 861 | "public team class Team413oicb2f {\n" + |
| 862 | " public class Role413oicb2f_1 playedBy T413oicb2f_1 {\n" + |
| 863 | " callin String test() {\n" + |
| 864 | " base.test();\n" + |
| 865 | " return \"NOTOK\";\n" + |
| 866 | " }\n" + |
| 867 | " String test() <- replace String getValue();\n" + |
| 868 | " }\n" + |
| 869 | "\n" + |
| 870 | " public class Role413oicb2f_2 extends Role413oicb2f_1 playedBy T413oicb2f_2 {\n" + |
| 871 | " callin String test() {\n" + |
| 872 | " base.test();\n" + |
| 873 | " return \"OK\";\n" + |
| 874 | " }\n" + |
| 875 | " test <- replace getValue;\n" + |
| 876 | " }\n" + |
| 877 | "}\n" + |
| 878 | " \n", |
| 879 | "T413oicb2f_1.java", |
| 880 | "\n" + |
| 881 | "public class T413oicb2f_1 {\n" + |
| 882 | " public String getValue() {\n" + |
| 883 | " return \"NOTOK\";\n" + |
| 884 | " }\n" + |
| 885 | "}\n" + |
| 886 | " \n", |
| 887 | "T413oicb2f_2.java", |
| 888 | "\n" + |
| 889 | "public class T413oicb2f_2 extends T413oicb2f_1 {}\n" + |
| 890 | " \n" |
| 891 | }, |
| 892 | "4.8"); |
| 893 | } |
| 894 | |
| 895 | // a role method is callin-bound as 'replace' and overwrites a replace callin-binding in the superrole - smart lifting selects the appropriate binding - independent role methods |
| 896 | // 4.1.3-otjld-overwriting-inherited-callin-binding-2g |
| 897 | public void test413_overwritingInheritedCallinBinding2g() { |
| 898 | runNegativeTestMatching( |
| 899 | new String[] { |
| 900 | "Team413oicb2g.java", |
| 901 | "\n" + |
| 902 | "public team class Team413oicb2g {\n" + |
| 903 | " public class Role413oicb2g_1 playedBy T413oicb2g_1 {\n" + |
| 904 | " callin String test1() {\n" + |
| 905 | " base.test1();\n" + |
| 906 | " return \"NOTOK\";\n" + |
| 907 | " }\n" + |
| 908 | " String test1() <- replace String getValue();\n" + |
| 909 | " }\n" + |
| 910 | "\n" + |
| 911 | " public class Role413oicb2g_2 extends Role413oicb2g_1 playedBy T413oicb2g_2 {\n" + |
| 912 | " callin String test2() {\n" + |
| 913 | " base.test2();\n" + |
| 914 | " return \"OK\";\n" + |
| 915 | " }\n" + |
| 916 | " test2 <- replace getValue;\n" + |
| 917 | " }\n" + |
| 918 | "}\n" + |
| 919 | " \n", |
| 920 | "T413oicb2g_1.java", |
| 921 | "\n" + |
| 922 | "public class T413oicb2g_1 {\n" + |
| 923 | " public String getValue() {\n" + |
| 924 | " return \"NOTOK\";\n" + |
| 925 | " }\n" + |
| 926 | "}\n" + |
| 927 | " \n", |
| 928 | "T413oicb2g_2.java", |
| 929 | "\n" + |
| 930 | "public class T413oicb2g_2 extends T413oicb2g_1 {}\n" + |
| 931 | " \n" |
| 932 | }, |
| 933 | "4.8"); |
| 934 | } |
| 935 | |
| 936 | // a role method is callin-bound as 'replace' and overwrites a before callin-binding in the remote superrole |
| 937 | // 4.1.3-otjld-overwriting-inherited-callin-binding-3 |
| 938 | public void test413_overwritingInheritedCallinBinding3() { |
| 939 | |
| 940 | runConformTest( |
| 941 | new String[] { |
| 942 | "T413oicb3Main.java", |
| 943 | "\n" + |
| 944 | "public class T413oicb3Main {\n" + |
| 945 | " public static void main(String[] args) {\n" + |
| 946 | " Team413oicb3_2 t = new Team413oicb3_2();\n" + |
| 947 | "\n" + |
| 948 | " within (t) {\n" + |
| 949 | " T413oicb3 o = new T413oicb3();\n" + |
| 950 | "\n" + |
| 951 | " System.out.print(o.getValue());\n" + |
| 952 | " }\n" + |
| 953 | " }\n" + |
| 954 | "}\n" + |
| 955 | " \n", |
| 956 | "T413oicb3.java", |
| 957 | "\n" + |
| 958 | "public class T413oicb3 {\n" + |
| 959 | " public static String value = null;\n" + |
| 960 | " public String getValue() {\n" + |
| 961 | " return value;\n" + |
| 962 | " }\n" + |
| 963 | "}\n" + |
| 964 | " \n", |
| 965 | "Team413oicb3_1.java", |
| 966 | "\n" + |
| 967 | "public team class Team413oicb3_1 {\n" + |
| 968 | " public class Role413oicb3_1 playedBy T413oicb3 {\n" + |
| 969 | " public void test() {\n" + |
| 970 | " T413oicb3.value = \"NOTOK\";\n" + |
| 971 | " }\n" + |
| 972 | " test <- before getValue;\n" + |
| 973 | " }\n" + |
| 974 | "}\n" + |
| 975 | " \n", |
| 976 | "Team413oicb3_2.java", |
| 977 | "\n" + |
| 978 | "public team class Team413oicb3_2 extends Team413oicb3_1 {\n" + |
| 979 | " public class Role413oicb3_2 extends Role413oicb3_1 {\n" + |
| 980 | " callin String getValue() {\n" + |
| 981 | " // we get a warning here but we do not want to call the base method\n" + |
| 982 | " return \"OK\";\n" + |
| 983 | " }\n" + |
| 984 | " getValue <- replace getValue;\n" + |
| 985 | " }\n" + |
| 986 | "}\n" + |
| 987 | " \n" |
| 988 | }, |
| 989 | "OK"); |
| 990 | //FIXME: expect this warning |
| 991 | } |
| 992 | |
| 993 | // an unbound role class has a callin binding |
| 994 | // 4.1.4-otjld-callin-binding-in-unbound-role-1 |
| 995 | public void test414_callinBindingInUnboundRole1() { |
| 996 | runNegativeTest( |
| 997 | new String[] { |
| 998 | "T414cbiur1.java", |
| 999 | "\n" + |
| 1000 | "public class T414cbiur1 {\n" + |
| 1001 | " public String getValue(String arg) {\n" + |
| 1002 | " return arg;\n" + |
| 1003 | " }\n" + |
| 1004 | "}\n" + |
| 1005 | " \n", |
| 1006 | "Team414cbiur1.java", |
| 1007 | "\n" + |
| 1008 | "public team class Team414cbiur1 {\n" + |
| 1009 | "\n" + |
| 1010 | " public class Role414cbiur1 extends T414cbiur1 {\n" + |
| 1011 | " public String getValue(String arg) {\n" + |
| 1012 | " return arg;\n" + |
| 1013 | " }\n" + |
| 1014 | " getValue <- after getValue;\n" + |
| 1015 | " }\n" + |
| 1016 | "}\n" + |
| 1017 | " \n" |
| 1018 | }, |
| 1019 | null); |
| 1020 | } |
| 1021 | |
| 1022 | // an unbound role class has a callin binding |
| 1023 | // 4.1.4-otjld-callin-binding-in-unbound-role-2 |
| 1024 | public void test414_callinBindingInUnboundRole2() { |
| 1025 | runNegativeTest( |
| 1026 | new String[] { |
| 1027 | "T414cbiur2.java", |
| 1028 | "\n" + |
| 1029 | "public class T414cbiur2 {\n" + |
| 1030 | " public String getValue(String arg) {\n" + |
| 1031 | " return arg;\n" + |
| 1032 | " }\n" + |
| 1033 | "}\n" + |
| 1034 | " \n", |
| 1035 | "Team414cbiur2.java", |
| 1036 | "\n" + |
| 1037 | "public team class Team414cbiur2 {\n" + |
| 1038 | "\n" + |
| 1039 | " public class Role414cbiur2_1 {\n" + |
| 1040 | " callin String getValue(String arg) {\n" + |
| 1041 | " return base.getValue(arg);\n" + |
| 1042 | " }\n" + |
| 1043 | " }\n" + |
| 1044 | "\n" + |
| 1045 | " public class Role414cbiur2_2 extends Role414cbiur2_1 {\n" + |
| 1046 | " getValue <- replace getValue;\n" + |
| 1047 | " }\n" + |
| 1048 | "}\n" + |
| 1049 | " \n" |
| 1050 | }, |
| 1051 | null); |
| 1052 | } |
| 1053 | |
| 1054 | // a role class callin-binds to a non-existing base method |
| 1055 | // 4.1.5-otjld-nonexisting-base-method-1 |
| 1056 | public void test415_nonexistingBaseMethod1() { |
| 1057 | runNegativeTest( |
| 1058 | new String[] { |
| 1059 | "T415nbm1.java", |
| 1060 | "\n" + |
| 1061 | "public class T415nbm1 {}\n" + |
| 1062 | " \n", |
| 1063 | "Team415nbm1.java", |
| 1064 | "\n" + |
| 1065 | "public team class Team415nbm1 {\n" + |
| 1066 | "\n" + |
| 1067 | " public class Role415nbm1 playedBy T415nbm1 {\n" + |
| 1068 | " public String getValue(String arg) {\n" + |
| 1069 | " return arg;\n" + |
| 1070 | " }\n" + |
| 1071 | " String getValue(String arg) <- after String getValue(String arg);\n" + |
| 1072 | " }\n" + |
| 1073 | "}\n" + |
| 1074 | " \n" |
| 1075 | }, |
| 1076 | null); |
| 1077 | } |
| 1078 | |
| 1079 | // a role class callin-binds to a non-existing base method |
| 1080 | // 4.1.5-otjld-nonexisting-base-method-2 |
| 1081 | public void test415_nonexistingBaseMethod2() { |
| 1082 | runNegativeTest( |
| 1083 | new String[] { |
| 1084 | "T415nbm2.java", |
| 1085 | "\n" + |
| 1086 | "public class T415nbm2 {\n" + |
| 1087 | " public String getValue(String arg) {\n" + |
| 1088 | " return arg;\n" + |
| 1089 | " }\n" + |
| 1090 | "}\n" + |
| 1091 | " \n", |
| 1092 | "Team415nbm2.java", |
| 1093 | "\n" + |
| 1094 | "public team class Team415nbm2 {\n" + |
| 1095 | "\n" + |
| 1096 | " public class Role415nbm2 playedBy T415nbm2 {\n" + |
| 1097 | " public String getValue(String arg) {\n" + |
| 1098 | " return arg;\n" + |
| 1099 | " }\n" + |
| 1100 | " getValue <- after getValue1;\n" + |
| 1101 | " }\n" + |
| 1102 | "}\n" + |
| 1103 | " \n" |
| 1104 | }, |
| 1105 | null); |
| 1106 | } |
| 1107 | |
| 1108 | // a role class callin-binds to a not-accessible base method |
| 1109 | // 4.1.5-otjld-nonexisting-base-method-3a |
| 1110 | public void test415_nonexistingBaseMethod3a() { |
| 1111 | |
| 1112 | runConformTest( |
| 1113 | new String[] { |
| 1114 | "Team415nbm3a.java", |
| 1115 | "\n" + |
| 1116 | "public team class Team415nbm3a {\n" + |
| 1117 | "\n" + |
| 1118 | " public class Role415nbm3a playedBy T415nbm3a {\n" + |
| 1119 | " public void test() {\n" + |
| 1120 | " System.out.print(\"O\");\n" + |
| 1121 | " }\n" + |
| 1122 | " void test() <- before void test(String arg);\n" + |
| 1123 | " }\n" + |
| 1124 | " Team415nbm3a () {\n" + |
| 1125 | " activate();\n" + |
| 1126 | " }\n" + |
| 1127 | " public static void main(String[] args) {\n" + |
| 1128 | " new Team415nbm3a();\n" + |
| 1129 | " (new T415nbm3a()).run();\n" + |
| 1130 | " }\n" + |
| 1131 | "}\n" + |
| 1132 | " \n", |
| 1133 | "T415nbm3a.java", |
| 1134 | "\n" + |
| 1135 | "public class T415nbm3a {\n" + |
| 1136 | " private void test(String arg) {\n" + |
| 1137 | " System.out.print(arg);\n" + |
| 1138 | " }\n" + |
| 1139 | " public void run() {\n" + |
| 1140 | " test(\"K\");\n" + |
| 1141 | " }\n" + |
| 1142 | "}\n" + |
| 1143 | " \n" |
| 1144 | }, |
| 1145 | "OK"); |
| 1146 | } |
| 1147 | |
| 1148 | // a role class callin-binds to a not-accessible base method - with base call |
| 1149 | // 4.1.5-otjld-nonexisting-base-method-3b |
| 1150 | public void test415_nonexistingBaseMethod3b() { |
| 1151 | runConformTest( |
| 1152 | new String[] { |
| 1153 | "T415nbm3bMain.java", |
| 1154 | "\n" + |
| 1155 | "public class T415nbm3bMain {\n" + |
| 1156 | " public static void main(String[] args) {\n" + |
| 1157 | " new Team415nbm3b();\n" + |
| 1158 | " (new T415nbm3b()).run();\n" + |
| 1159 | " }\n" + |
| 1160 | "}\n" + |
| 1161 | " \n", |
| 1162 | "T415nbm3b.java", |
| 1163 | "\n" + |
| 1164 | "public class T415nbm3b {\n" + |
| 1165 | " private void test(String arg) {\n" + |
| 1166 | " System.out.print(arg);\n" + |
| 1167 | " }\n" + |
| 1168 | " public void run() {\n" + |
| 1169 | " test(\"K\");\n" + |
| 1170 | " }\n" + |
| 1171 | "}\n" + |
| 1172 | " \n", |
| 1173 | "Team415nbm3b.java", |
| 1174 | "\n" + |
| 1175 | "public team class Team415nbm3b {\n" + |
| 1176 | "\n" + |
| 1177 | " public class Role415nbm3b playedBy T415nbm3b {\n" + |
| 1178 | " callin void test() {\n" + |
| 1179 | " System.out.print(\"O\");\n" + |
| 1180 | " base.test();\n" + |
| 1181 | " }\n" + |
| 1182 | " void test() <- replace void test(String arg);\n" + |
| 1183 | " }\n" + |
| 1184 | " Team415nbm3b () {\n" + |
| 1185 | " activate();\n" + |
| 1186 | " }\n" + |
| 1187 | "}\n" + |
| 1188 | " \n" |
| 1189 | }, |
| 1190 | "OK"); |
| 1191 | } |
| 1192 | |
| 1193 | // a role class callin-binds to a not-accessible base method - with base call - double compile |
| 1194 | // 4.1.5-otjld-nonexisting-base-method-3f |
| 1195 | public void test415_nonexistingBaseMethod3f() { |
| 1196 | |
| 1197 | runConformTest( |
| 1198 | new String[] { |
| 1199 | "T415nbm3fMain.java", |
| 1200 | "\n" + |
| 1201 | "public class T415nbm3fMain {\n" + |
| 1202 | " public static void main(String[] args) {\n" + |
| 1203 | " new Team415nbm3f();\n" + |
| 1204 | " (new T415nbm3f()).run();\n" + |
| 1205 | " }\n" + |
| 1206 | "}\n" + |
| 1207 | " \n", |
| 1208 | "T415nbm3f.java", |
| 1209 | "\n" + |
| 1210 | "public class T415nbm3f {\n" + |
| 1211 | " private void test(String arg) {\n" + |
| 1212 | " System.out.print(arg);\n" + |
| 1213 | " }\n" + |
| 1214 | " public void run() {\n" + |
| 1215 | " test(\"K\");\n" + |
| 1216 | " }\n" + |
| 1217 | "}\n" + |
| 1218 | " \n", |
| 1219 | "Team415nbm3f.java", |
| 1220 | "\n" + |
| 1221 | "public team class Team415nbm3f {\n" + |
| 1222 | "\n" + |
| 1223 | " public class Role415nbm3f playedBy T415nbm3f {\n" + |
| 1224 | " callin void test() {\n" + |
| 1225 | " System.out.print(\"O\");\n" + |
| 1226 | " base.test();\n" + |
| 1227 | " }\n" + |
| 1228 | " void test() <- replace void test(String arg);\n" + |
| 1229 | " }\n" + |
| 1230 | " Team415nbm3f () {\n" + |
| 1231 | " activate();\n" + |
| 1232 | " }\n" + |
| 1233 | "}\n" + |
| 1234 | " \n" |
| 1235 | }, |
| 1236 | "OK"); |
| 1237 | } |
| 1238 | |
| 1239 | // a role class CALLOUT-binds to a not-accessible inherited base method - error case |
| 1240 | // 4.1.5-otjld-nonexisting-base-method-3co |
| 1241 | public void test415_nonexistingBaseMethod3co() { |
| 1242 | runNegativeTestMatching( |
| 1243 | new String[] { |
| 1244 | "Team415nbm3co.java", |
| 1245 | "\n" + |
| 1246 | "public team class Team415nbm3co {\n" + |
| 1247 | "\n" + |
| 1248 | " public class Role415nbm3co playedBy T415nbm3co_2 {\n" + |
| 1249 | " void test(String arg) -> void test(String arg);\n" + |
| 1250 | " }\n" + |
| 1251 | "}\n" + |
| 1252 | " \n", |
| 1253 | "T415nbm3co_1.java", |
| 1254 | "\n" + |
| 1255 | "public class T415nbm3co_1 {\n" + |
| 1256 | " private void test(String arg) {\n" + |
| 1257 | " System.out.print(arg);\n" + |
| 1258 | " }\n" + |
| 1259 | " public void run() {\n" + |
| 1260 | " test(\"K\");\n" + |
| 1261 | " }\n" + |
| 1262 | "}\n" + |
| 1263 | " \n", |
| 1264 | "T415nbm3co_2.java", |
| 1265 | "\n" + |
| 1266 | "public class T415nbm3co_2 extends T415nbm3co_1 {\n" + |
| 1267 | "}\n" + |
| 1268 | " \n" |
| 1269 | }, |
| 1270 | "3.4(d)"); |
| 1271 | } |
| 1272 | |
| 1273 | // a role class callin-binds to a not-accessible inherited base method - error case |
| 1274 | // 4.1.5-otjld-nonexisting-base-method-3h |
| 1275 | public void test415_nonexistingBaseMethod3h() { |
| 1276 | runNegativeTestMatching( |
| 1277 | new String[] { |
| 1278 | "Team415nbm3h.java", |
| 1279 | "\n" + |
| 1280 | "public team class Team415nbm3h {\n" + |
| 1281 | "\n" + |
| 1282 | " public class Role415nbm3h playedBy T415nbm3h_2 {\n" + |
| 1283 | " public void test() {\n" + |
| 1284 | " System.out.print(\"O\");\n" + |
| 1285 | " }\n" + |
| 1286 | " void test() <- before void test(String arg);\n" + |
| 1287 | " }\n" + |
| 1288 | "}\n" + |
| 1289 | " \n", |
| 1290 | "T415nbm3h_1.java", |
| 1291 | "\n" + |
| 1292 | "public class T415nbm3h_1 {\n" + |
| 1293 | " private void test(String arg) {\n" + |
| 1294 | " System.out.print(arg);\n" + |
| 1295 | " }\n" + |
| 1296 | " public void run() {\n" + |
| 1297 | " test(\"K\");\n" + |
| 1298 | " }\n" + |
| 1299 | "}\n" + |
| 1300 | " \n", |
| 1301 | "T415nbm3h_2.java", |
| 1302 | "\n" + |
| 1303 | "public class T415nbm3h_2 extends T415nbm3h_1 {\n" + |
| 1304 | "}\n" + |
| 1305 | " \n" |
| 1306 | }, |
| 1307 | "4.6(a)"); |
| 1308 | } |
| 1309 | |
| 1310 | // a role class callin-binds to a not-accessible inherited base method - corrected |
| 1311 | // 4.1.5-otjld-nonexisting-base-method-3i |
| 1312 | public void test415_nonexistingBaseMethod3i() { |
Stephan Herrmann | 7aa4219 | 2011-05-10 23:29:37 +0000 | [diff] [blame] | 1313 | Map options = getCompilerOptions(); |
| 1314 | options.put(CompilerOptions.OPTION_ReportHiddenLiftingProblem, CompilerOptions.WARNING); |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 1315 | runConformTest( |
| 1316 | new String[] { |
| 1317 | "Team415nbm3i.java", |
Stephan Herrmann | 7aa4219 | 2011-05-10 23:29:37 +0000 | [diff] [blame] | 1318 | "import org.objectteams.LiftingFailedException;\n" + |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 1319 | "public team class Team415nbm3i {\n" + |
| 1320 | " @SuppressWarnings(\"abstractrelevantrole\")\n" + |
| 1321 | " protected abstract class Role415nbm3i_1 playedBy T415nbm3i_1 {\n" + |
| 1322 | " public abstract void test();\n" + |
Stephan Herrmann | 7aa4219 | 2011-05-10 23:29:37 +0000 | [diff] [blame] | 1323 | " @SuppressWarnings(\"hidden-lifting-problem\")\n" + |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 1324 | " void test() <- before void test(String arg);\n" + |
| 1325 | " }\n" + |
| 1326 | " public class Role415nbm3i_2 extends Role415nbm3i_1 playedBy T415nbm3i_2 {\n" + |
| 1327 | " public void test() {\n" + |
| 1328 | " System.out.print(\"O\");\n" + |
| 1329 | " }\n" + |
| 1330 | " }\n" + |
| 1331 | " Team415nbm3i () {\n" + |
| 1332 | " activate();\n" + |
| 1333 | " }\n" + |
| 1334 | " public static void main(String[] args) {\n" + |
| 1335 | " new Team415nbm3i();\n" + |
| 1336 | " (new T415nbm3i_2()).run();\n" + |
| 1337 | " }\n" + |
| 1338 | "}\n" + |
| 1339 | " \n", |
| 1340 | "T415nbm3i_1.java", |
| 1341 | "\n" + |
| 1342 | "public abstract class T415nbm3i_1 {\n" + |
| 1343 | " private void test(String arg) {\n" + |
| 1344 | " System.out.print(arg);\n" + |
| 1345 | " }\n" + |
| 1346 | " public void run() {\n" + |
| 1347 | " test(\"K\");\n" + |
| 1348 | " }\n" + |
| 1349 | "}\n" + |
| 1350 | " \n", |
| 1351 | "T415nbm3i_2.java", |
| 1352 | "\n" + |
| 1353 | "public class T415nbm3i_2 extends T415nbm3i_1 {\n" + |
| 1354 | "}\n" + |
| 1355 | " \n" |
| 1356 | }, |
Stephan Herrmann | 7aa4219 | 2011-05-10 23:29:37 +0000 | [diff] [blame] | 1357 | "OK", |
| 1358 | null/*classLibs*/, |
| 1359 | true/*shouldFlush*/, |
| 1360 | null/*vmArguments*/, |
| 1361 | options, |
| 1362 | null/*requester*/); |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 1363 | } |
| 1364 | |
| 1365 | // a role class callin-binds to a not-accessible base method |
| 1366 | // 4.1.5-otjld-nonexisting-base-method-4 |
| 1367 | public void test415_nonexistingBaseMethod4() { |
| 1368 | |
| 1369 | runConformTest( |
| 1370 | new String[] { |
| 1371 | "p2/Team415nbm4.java", |
| 1372 | "\n" + |
| 1373 | "package p2;\n" + |
| 1374 | "public team class Team415nbm4 {\n" + |
| 1375 | " @SuppressWarnings(\"bindingconventions\") // re base import vs. fqn\n" + |
| 1376 | " public class Role415nbm4 playedBy p1.T415nbm4 {\n" + |
| 1377 | " public void check() {\n" + |
| 1378 | " System.out.print(\"O\");\n" + |
| 1379 | " }\n" + |
| 1380 | " check <- before test;\n" + |
| 1381 | " }\n" + |
| 1382 | " Team415nbm4 () {\n" + |
| 1383 | " activate();\n" + |
| 1384 | " }\n" + |
| 1385 | " public static void main(String[] args) {\n" + |
| 1386 | " new Team415nbm4();\n" + |
| 1387 | " (new p1.T415nbm4()).run();\n" + |
| 1388 | " }\n" + |
| 1389 | "}\n" + |
| 1390 | " \n", |
| 1391 | "p1/T415nbm4.java", |
| 1392 | "\n" + |
| 1393 | "package p1;\n" + |
| 1394 | "public class T415nbm4 {\n" + |
| 1395 | " void test(String arg) {\n" + |
| 1396 | " System.out.print(arg);\n" + |
| 1397 | " }\n" + |
| 1398 | " public void run() {\n" + |
| 1399 | " test(\"K\");\n" + |
| 1400 | " } \n" + |
| 1401 | "}\n" + |
| 1402 | " \n" |
| 1403 | }, |
| 1404 | "OK"); |
| 1405 | } |
| 1406 | |
| 1407 | // a role class callin-binds to a base method with a signature that has no return type whereas the actual base method has one |
| 1408 | // 4.1.5-otjld-nonexisting-base-method-5 |
| 1409 | public void test415_nonexistingBaseMethod5() { |
| 1410 | runNegativeTest( |
| 1411 | new String[] { |
| 1412 | "T415nbm5.java", |
| 1413 | "\n" + |
| 1414 | "public class T415nbm5 {\n" + |
| 1415 | " public String getValue() {\n" + |
| 1416 | " return null;\n" + |
| 1417 | " }\n" + |
| 1418 | "}\n" + |
| 1419 | " \n", |
| 1420 | "Team415nbm5.java", |
| 1421 | "\n" + |
| 1422 | "public team class Team415nbm5 {\n" + |
| 1423 | "\n" + |
| 1424 | " public class Role415nbm5 playedBy T415nbm5 {\n" + |
| 1425 | " public void test() {}\n" + |
| 1426 | " void test() <- before void getValue();\n" + |
| 1427 | " }\n" + |
| 1428 | "}\n" + |
| 1429 | " \n" |
| 1430 | }, |
| 1431 | null); |
| 1432 | } |
| 1433 | |
| 1434 | // a role class callin-binds as 'replace' a role method with no return type whereas the base method has one |
| 1435 | // 4.1.5-otjld-nonexisting-base-method-6 |
| 1436 | public void test415_nonexistingBaseMethod6() { |
| 1437 | |
| 1438 | runConformTest( |
| 1439 | new String[] { |
| 1440 | "Team415nbm6.java", |
| 1441 | "\n" + |
| 1442 | "public team class Team415nbm6 {\n" + |
| 1443 | "\n" + |
| 1444 | " public class Role415nbm6 playedBy T415nbm6 {\n" + |
| 1445 | " callin void test() {\n" + |
| 1446 | " setValue(\"O\");\n" + |
| 1447 | " base.test();\n" + |
| 1448 | " }\n" + |
| 1449 | " abstract void setValue(String s);\n" + |
| 1450 | " test <- replace test;\n" + |
| 1451 | " setValue -> setValue;\n" + |
| 1452 | " }\n" + |
| 1453 | " public Team415nbm6() {\n" + |
| 1454 | " activate();\n" + |
| 1455 | " T415nbm6 o = new T415nbm6();\n" + |
| 1456 | " System.out.print(o.test());\n" + |
| 1457 | " }\n" + |
| 1458 | " public static void main(String [] args) {\n" + |
| 1459 | " new Team415nbm6();\n" + |
| 1460 | " }\n" + |
| 1461 | "}\n" + |
| 1462 | " \n", |
| 1463 | "T415nbm6.java", |
| 1464 | "\n" + |
| 1465 | "public class T415nbm6 {\n" + |
| 1466 | " private String value=\"\";\n" + |
| 1467 | " public String test() {\n" + |
| 1468 | " return value+\"K\";\n" + |
| 1469 | " }\n" + |
| 1470 | " public String setValue(String s) {\n" + |
| 1471 | " value = s;\n" + |
| 1472 | " return value;\n" + |
| 1473 | " }\n" + |
| 1474 | "}\n" + |
| 1475 | " \n" |
| 1476 | }, |
| 1477 | "OK"); |
| 1478 | } |
| 1479 | |
| 1480 | // a role class callin-binds to a base method with a signature that has a return type whereas the actual base method has none |
| 1481 | // 4.1.5-otjld-nonexisting-base-method-7 |
| 1482 | public void test415_nonexistingBaseMethod7() { |
| 1483 | runNegativeTest( |
| 1484 | new String[] { |
| 1485 | "T415nbm7.java", |
| 1486 | "\n" + |
| 1487 | "public class T415nbm7 {\n" + |
| 1488 | " public void test() {}\n" + |
| 1489 | "}\n" + |
| 1490 | " \n", |
| 1491 | "Team415nbm7.java", |
| 1492 | "\n" + |
| 1493 | "public team class Team415nbm7 {\n" + |
| 1494 | "\n" + |
| 1495 | " public class Role415nbm7 playedBy T415nbm7 {\n" + |
| 1496 | " protected String test() {\n" + |
| 1497 | " return null;\n" + |
| 1498 | " }\n" + |
| 1499 | " String test() <- after String test();\n" + |
| 1500 | " }\n" + |
| 1501 | "}\n" + |
| 1502 | " \n" |
| 1503 | }, |
| 1504 | null); |
| 1505 | } |
| 1506 | |
| 1507 | // a role class callin-binds as 'replace' a role method with a return type whereas the base method has none |
| 1508 | // 4.1.5-otjld-nonexisting-base-method-8 |
| 1509 | public void test415_nonexistingBaseMethod8() { |
| 1510 | runNegativeTest( |
| 1511 | new String[] { |
| 1512 | "T415nbm8.java", |
| 1513 | "\n" + |
| 1514 | "public class T415nbm8 {\n" + |
| 1515 | " public void test() {}\n" + |
| 1516 | "}\n" + |
| 1517 | " \n", |
| 1518 | "Team415nbm8.java", |
| 1519 | "\n" + |
| 1520 | "public team class Team415nbm8 {\n" + |
| 1521 | "\n" + |
| 1522 | " public class Role415nbm8 playedBy T415nbm8 {\n" + |
| 1523 | " callin String getValue() {\n" + |
| 1524 | " return base.getValue();\n" + |
| 1525 | " }\n" + |
| 1526 | " getValue <- replace test;\n" + |
| 1527 | " }\n" + |
| 1528 | "}\n" + |
| 1529 | " \n" |
| 1530 | }, |
| 1531 | null); |
| 1532 | } |
| 1533 | |
| 1534 | // a role class callin-binds as 'replace' to a base method with a signature that is different from the signature of the actual base method |
| 1535 | // 4.1.5-otjld-nonexisting-base-method-9 |
| 1536 | public void test415_nonexistingBaseMethod9() { |
| 1537 | runNegativeTest( |
| 1538 | new String[] { |
| 1539 | "T415nbm9.java", |
| 1540 | "\n" + |
| 1541 | "public class T415nbm9 {\n" + |
| 1542 | " public void test(String arg1, int arg2) {}\n" + |
| 1543 | "}\n" + |
| 1544 | " \n", |
| 1545 | "Team415nbm9.java", |
| 1546 | "\n" + |
| 1547 | "public team class Team415nbm9 {\n" + |
| 1548 | "\n" + |
| 1549 | " public class Role415nbm9 playedBy T415nbm9 {\n" + |
| 1550 | " callin void test() {\n" + |
| 1551 | " base.test();\n" + |
| 1552 | " }\n" + |
| 1553 | " void test() <- replace void test(String arg1, short arg2);\n" + |
| 1554 | " }\n" + |
| 1555 | "}\n" + |
| 1556 | " \n" |
| 1557 | }, |
| 1558 | null); |
| 1559 | } |
| 1560 | |
| 1561 | // a role class callin-binds as 'replace' to a base method with a signature that is different from the signature of the actual base method |
| 1562 | // 4.1.5-otjld-nonexisting-base-method-10 |
| 1563 | public void test415_nonexistingBaseMethod10() { |
| 1564 | runNegativeTest( |
| 1565 | new String[] { |
| 1566 | "T415nbm10.java", |
| 1567 | "\n" + |
| 1568 | "public class T415nbm10 {\n" + |
| 1569 | " public void test(int arg1, int arg2) {}\n" + |
| 1570 | "}\n" + |
| 1571 | " \n", |
| 1572 | "Team415nbm10.java", |
| 1573 | "\n" + |
| 1574 | "public team class Team415nbm10 {\n" + |
| 1575 | "\n" + |
| 1576 | " public class Role415nbm10 playedBy T415nbm10 {\n" + |
| 1577 | " callin void test1(long arg1, short arg2) {\n" + |
| 1578 | " base.test1(arg1, arg2);\n" + |
| 1579 | " }\n" + |
| 1580 | " test1 <- replace test;\n" + |
| 1581 | " }\n" + |
| 1582 | "}\n" + |
| 1583 | " \n" |
| 1584 | }, |
| 1585 | null); |
| 1586 | } |
| 1587 | |
| 1588 | // a role class callin-binds to a base method with a signature that has less parameters than the real base method |
| 1589 | // 4.1.5-otjld-nonexisting-base-method-11 |
| 1590 | public void test415_nonexistingBaseMethod11() { |
| 1591 | runNegativeTest( |
| 1592 | new String[] { |
| 1593 | "T415nbm11.java", |
| 1594 | "\n" + |
| 1595 | "public class T415nbm11 {\n" + |
| 1596 | " public void test(String arg) {}\n" + |
| 1597 | "}\n" + |
| 1598 | " \n", |
| 1599 | "Team415nbm11.java", |
| 1600 | "\n" + |
| 1601 | "public team class Team415nbm11 {\n" + |
| 1602 | "\n" + |
| 1603 | " public class Role415nbm11 playedBy T415nbm11 {\n" + |
| 1604 | " public void test() {}\n" + |
| 1605 | " void test() <- after void test();\n" + |
| 1606 | " }\n" + |
| 1607 | "}\n" + |
| 1608 | " \n" |
| 1609 | }, |
| 1610 | null); |
| 1611 | } |
| 1612 | |
| 1613 | // a role class callin-binds to a base method with a signature that has more parameters than the real base method |
| 1614 | // 4.1.5-otjld-nonexisting-base-method-12 |
| 1615 | public void test415_nonexistingBaseMethod12() { |
| 1616 | runNegativeTest( |
| 1617 | new String[] { |
| 1618 | "T415nbm12.java", |
| 1619 | "\n" + |
| 1620 | "public class T415nbm12 {\n" + |
| 1621 | " public void test() {}\n" + |
| 1622 | "}\n" + |
| 1623 | " \n", |
| 1624 | "Team415nbm12.java", |
| 1625 | "\n" + |
| 1626 | "public team class Team415nbm12 {\n" + |
| 1627 | "\n" + |
| 1628 | " public class Role415nbm12 playedBy T415nbm12 {\n" + |
| 1629 | " public void test1(String arg) {}\n" + |
| 1630 | " void test1(String arg) <- after void test(String arg);\n" + |
| 1631 | " }\n" + |
| 1632 | "}\n" + |
| 1633 | " \n" |
| 1634 | }, |
| 1635 | null); |
| 1636 | } |
| 1637 | |
| 1638 | // a role class callin-binds a role method with more parameters than the bound base method |
| 1639 | // 4.1.5-otjld-nonexisting-base-method-13 |
| 1640 | public void test415_nonexistingBaseMethod13() { |
| 1641 | runNegativeTest( |
| 1642 | new String[] { |
| 1643 | "T415nbm13.java", |
| 1644 | "\n" + |
| 1645 | "public class T415nbm13 {\n" + |
| 1646 | " public void test() {}\n" + |
| 1647 | "}\n" + |
| 1648 | " \n", |
| 1649 | "Team415nbm13.java", |
| 1650 | "\n" + |
| 1651 | "public team class Team415nbm13 {\n" + |
| 1652 | "\n" + |
| 1653 | " public class Role415nbm13 playedBy T415nbm13 {\n" + |
| 1654 | " public void test1(String arg) {}\n" + |
| 1655 | " test1 <- before test;\n" + |
| 1656 | " }\n" + |
| 1657 | "}\n" + |
| 1658 | " \n" |
| 1659 | }, |
| 1660 | null); |
| 1661 | } |
| 1662 | |
| 1663 | // a role class callin-binds as 'replace' a role method with more parameters than the bound base method |
| 1664 | // 4.1.5-otjld-nonexisting-base-method-14 |
| 1665 | public void test415_nonexistingBaseMethod14() { |
| 1666 | runNegativeTest( |
| 1667 | new String[] { |
| 1668 | "T415nbm14.java", |
| 1669 | "\n" + |
| 1670 | "public class T415nbm14 {\n" + |
| 1671 | " public void test(String arg) {}\n" + |
| 1672 | "}\n" + |
| 1673 | " \n", |
| 1674 | "Team415nbm14.java", |
| 1675 | "\n" + |
| 1676 | "public team class Team415nbm14 {\n" + |
| 1677 | "\n" + |
| 1678 | " public class Role415nbm14 playedBy T415nbm14 {\n" + |
| 1679 | " callin void test(String arg1, String arg2) {\n" + |
| 1680 | " base.test(arg1, arg2);\n" + |
| 1681 | " }\n" + |
| 1682 | " test <- replace test;\n" + |
| 1683 | " }\n" + |
| 1684 | "}\n" + |
| 1685 | " \n" |
| 1686 | }, |
| 1687 | null); |
| 1688 | } |
| 1689 | |
| 1690 | // a role class callin-binds as 'replace' to a base method while omitting the return type |
| 1691 | // 4.1.5-otjld-nonexisting-base-method-15 |
| 1692 | public void test415_nonexistingBaseMethod15() { |
| 1693 | runNegativeTest( |
| 1694 | new String[] { |
| 1695 | "Team415nbm15.java", |
| 1696 | "\n" + |
| 1697 | "public team class Team415nbm15 {\n" + |
| 1698 | "\n" + |
| 1699 | " public class Role415nbm15 playedBy T415nbm15 {\n" + |
| 1700 | " test <- replace test(String a);\n" + |
| 1701 | " callin void test(String arg1) {\n" + |
| 1702 | " base.test(arg1);\n" + |
| 1703 | " }\n" + |
| 1704 | " }\n" + |
| 1705 | "}\n" + |
| 1706 | " \n", |
| 1707 | "T415nbm15.java", |
| 1708 | "\n" + |
| 1709 | "public class T415nbm15 {\n" + |
| 1710 | " public int test(String arg) { return 3; }\n" + |
| 1711 | "}\n" + |
| 1712 | " \n" |
| 1713 | }, |
| 1714 | "----------\n" + |
| 1715 | "1. ERROR in Team415nbm15.java (at line 5)\n" + |
| 1716 | " test <- replace test(String a);\n" + |
| 1717 | " ^^^^^^^\n" + |
| 1718 | "Syntax error on token \"replace\", invalid MethodSpecsShort\n" + |
| 1719 | "----------\n"); |
| 1720 | } |
| 1721 | |
| 1722 | // a callin-binding states a modifier |
| 1723 | // 4.1.6-otjld-callin-binding-states-modifier-1 |
| 1724 | public void test416_callinBindingStatesModifier1() { |
| 1725 | runNegativeTestMatching( |
| 1726 | new String[] { |
| 1727 | "Team416bsm1.java", |
| 1728 | "\n" + |
| 1729 | "public team class Team416bsm1 {\n" + |
| 1730 | "\n" + |
| 1731 | " public class Role416bsm1 playedBy T416bsm1 {\n" + |
| 1732 | " public void test() {}\n" + |
| 1733 | " public void test() <- before void test();\n" + |
| 1734 | " }\n" + |
| 1735 | "}\n" + |
| 1736 | " \n", |
| 1737 | "T416bsm1.java", |
| 1738 | "\n" + |
| 1739 | "public class T416bsm1 {\n" + |
| 1740 | " public void test() {}\n" + |
| 1741 | "}\n" + |
| 1742 | " \n" |
| 1743 | }, |
| 1744 | "A.3.3"); |
| 1745 | } |
| 1746 | |
| 1747 | // a callin-binding states a modifier |
| 1748 | // 4.1.6-otjld-callin-binding-states-modifier-2 |
| 1749 | public void test416_callinBindingStatesModifier2() { |
| 1750 | runNegativeTestMatching( |
| 1751 | new String[] { |
| 1752 | "Team416bsm2.java", |
| 1753 | "\n" + |
| 1754 | "public team class Team416bsm2 {\n" + |
| 1755 | "\n" + |
| 1756 | " public class Role416bsm2 playedBy T416bsm2 {\n" + |
| 1757 | " public void doSomething() {}\n" + |
| 1758 | " void doSomething() <- after private void test();\n" + |
| 1759 | " }\n" + |
| 1760 | "}\n" + |
| 1761 | " \n", |
| 1762 | "T416bsm2.java", |
| 1763 | "\n" + |
| 1764 | "public class T416bsm2 {\n" + |
| 1765 | " public void test() {}\n" + |
| 1766 | "}\n" + |
| 1767 | " \n" |
| 1768 | }, |
| 1769 | "A.3.5"); |
| 1770 | } |
| 1771 | |
| 1772 | // a callin-binding states a modifier |
| 1773 | // 4.1.6-otjld-callin-binding-states-modifier-3 |
| 1774 | public void test416_callinBindingStatesModifier3() { |
| 1775 | runNegativeTestMatching( |
| 1776 | new String[] { |
| 1777 | "Team416bsm3.java", |
| 1778 | "\n" + |
| 1779 | "public team class Team416bsm3 {\n" + |
| 1780 | "\n" + |
| 1781 | " public class Role416bsm3 playedBy T416bsm3 {\n" + |
| 1782 | " callin void test(String arg) {\n" + |
| 1783 | " base.test(arg);\n" + |
| 1784 | " }\n" + |
| 1785 | " void test(String arg) <- replace abstract void test(String arg);\n" + |
| 1786 | " }\n" + |
| 1787 | "}\n" + |
| 1788 | " \n", |
| 1789 | "T416bsm3.java", |
| 1790 | "\n" + |
| 1791 | "public abstract class T416bsm3 {\n" + |
| 1792 | " public abstract void test(String arg);\n" + |
| 1793 | "}\n" + |
| 1794 | " \n" |
| 1795 | }, |
| 1796 | "A.3.5"); |
| 1797 | } |
| 1798 | |
| 1799 | // a callin-binding states a modifier |
| 1800 | // 4.1.6-otjld-callin-binding-states-modifier-4 |
| 1801 | public void test416_callinBindingStatesModifier4() { |
| 1802 | runNegativeTestMatching( |
| 1803 | new String[] { |
| 1804 | "Team416bsm4.java", |
| 1805 | "\n" + |
| 1806 | "public team class Team416bsm4 {\n" + |
| 1807 | "\n" + |
| 1808 | " public class Role416bsm4 playedBy T416bsm4 {\n" + |
| 1809 | " callin void doSomething(String arg) {\n" + |
| 1810 | " base.doSomething(arg);\n" + |
| 1811 | " }\n" + |
| 1812 | " static void doSomething(String arg) <- replace void test(String arg1, String arg2);\n" + |
| 1813 | " }\n" + |
| 1814 | "}\n" + |
| 1815 | " \n", |
| 1816 | "T416bsm4.java", |
| 1817 | "\n" + |
| 1818 | "public class T416bsm4 {\n" + |
| 1819 | " public void test(String arg1, String arg2) {}\n" + |
| 1820 | "}\n" + |
| 1821 | " \n" |
| 1822 | }, |
| 1823 | "A.3.3"); |
| 1824 | } |
| 1825 | |
| 1826 | // a callin-binding states a modifier |
| 1827 | // 4.1.6-otjld-callin-binding-states-modifier-5 |
| 1828 | public void test416_callinBindingStatesModifier5() { |
| 1829 | runNegativeTestMatching( |
| 1830 | new String[] { |
| 1831 | "Team416bsm5.java", |
| 1832 | "\n" + |
| 1833 | "public team class Team416bsm5 {\n" + |
| 1834 | "\n" + |
| 1835 | " public class Role416bsm5 playedBy T416bsm5 {\n" + |
| 1836 | " public void doSomething(String arg) {}\n" + |
| 1837 | " void doSomething(String arg) <- before synchronized void test(String arg);\n" + |
| 1838 | " }\n" + |
| 1839 | "}\n" + |
| 1840 | " \n", |
| 1841 | "T416bsm5.java", |
| 1842 | "\n" + |
| 1843 | "public class T416bsm5 {\n" + |
| 1844 | " public synchronized void test(String arg) {}\n" + |
| 1845 | "}\n" + |
| 1846 | " \n" |
| 1847 | }, |
| 1848 | "A.3.5"); |
| 1849 | } |
| 1850 | |
| 1851 | // a callin-binding states a modifier |
| 1852 | // 4.1.6-otjld-callin-binding-states-modifier-6 |
| 1853 | public void test416_callinBindingStatesModifier6() { |
| 1854 | runNegativeTestMatching( |
| 1855 | new String[] { |
| 1856 | "Team416bsm6.java", |
| 1857 | "\n" + |
| 1858 | "public team class Team416bsm6 {\n" + |
| 1859 | "\n" + |
| 1860 | " public class Role416bsm6 playedBy T416bsm6 {\n" + |
| 1861 | " protected void test() {}\n" + |
| 1862 | " protected test <- after test;\n" + |
| 1863 | " }\n" + |
| 1864 | "}\n" + |
| 1865 | " \n", |
| 1866 | "T416bsm6.java", |
| 1867 | "\n" + |
| 1868 | "public class T416bsm6 {\n" + |
| 1869 | " public void test() {}\n" + |
| 1870 | "}\n" + |
| 1871 | " \n" |
| 1872 | }, |
| 1873 | "A.3.3"); |
| 1874 | } |
| 1875 | |
| 1876 | // a callin-binding states a modifier |
| 1877 | // 4.1.6-otjld-callin-binding-states-modifier-7 |
| 1878 | public void test416_callinBindingStatesModifier7() { |
| 1879 | runNegativeTestMatching( |
| 1880 | new String[] { |
| 1881 | "Team416bsm7.java", |
| 1882 | "\n" + |
| 1883 | "public team class Team416bsm7 {\n" + |
| 1884 | "\n" + |
| 1885 | " public class Role416bsm7 playedBy T416bsm7 {\n" + |
| 1886 | " callin void doSomething(String arg) {\n" + |
| 1887 | " base.doSomething(arg);\n" + |
| 1888 | " }\n" + |
| 1889 | " doSomething <- replace abstract test;\n" + |
| 1890 | " }\n" + |
| 1891 | "}\n" + |
| 1892 | " \n", |
| 1893 | "T416bsm7.java", |
| 1894 | "\n" + |
| 1895 | "public class T416bsm7 {\n" + |
| 1896 | " public void test(String arg) {}\n" + |
| 1897 | "}\n" + |
| 1898 | " \n" |
| 1899 | }, |
| 1900 | "Syntax"); |
| 1901 | } |
| 1902 | |
| 1903 | // a callin-binding uses <= instead of <- |
| 1904 | // 4.1.7-otjld-wrong-callin-binding-operator |
| 1905 | public void test417_wrongCallinBindingOperator() { |
| 1906 | runNegativeTest( |
| 1907 | new String[] { |
| 1908 | "T417wcbo.java", |
| 1909 | "\n" + |
| 1910 | "public class T417wcbo {\n" + |
| 1911 | " public void test() {}\n" + |
| 1912 | "}\n" + |
| 1913 | " \n", |
| 1914 | "Team417wcbo.java", |
| 1915 | "\n" + |
| 1916 | "public team class Team417wcbo {\n" + |
| 1917 | "\n" + |
| 1918 | " public class Role417wcbo playedBy T417wcbo {\n" + |
| 1919 | " protected void test() {}\n" + |
| 1920 | " test <= after test;\n" + |
| 1921 | " }\n" + |
| 1922 | "}\n" + |
| 1923 | " \n" |
| 1924 | }, |
| 1925 | null); |
| 1926 | } |
| 1927 | |
| 1928 | // a regular method is replace-bound |
| 1929 | // 4.1.8-otjld-wrong-callin-combination-1 |
| 1930 | public void test418_wrongCallinCombination1() { |
| 1931 | runNegativeTestMatching( |
| 1932 | new String[] { |
| 1933 | "Team418wcc1.java", |
| 1934 | "\n" + |
| 1935 | "import base java.util.ArrayList;\n" + |
| 1936 | "public team class Team418wcc1 {\n" + |
| 1937 | " @SuppressWarnings(\"unchecked\")\n" + |
| 1938 | " protected class R playedBy ArrayList {\n" + |
| 1939 | " void wrong() {}\n" + |
| 1940 | " wrong <- replace size;\n" + |
| 1941 | " }\n" + |
| 1942 | "}\n" + |
| 1943 | " \n" |
| 1944 | }, |
| 1945 | "4.2(d)"); |
| 1946 | } |
| 1947 | |
| 1948 | // a role class callin-binds a non-existing role method |
| 1949 | // 4.1.9-otjld-nonexisting-role-method-1 |
| 1950 | public void test419_nonexistingRoleMethod1() { |
| 1951 | runNegativeTest( |
| 1952 | new String[] { |
| 1953 | "T419nrm1.java", |
| 1954 | "\n" + |
| 1955 | "public class T419nrm1 {\n" + |
| 1956 | " public String getValue(String arg) {\n" + |
| 1957 | " return arg;\n" + |
| 1958 | " }\n" + |
| 1959 | "}\n" + |
| 1960 | " \n", |
| 1961 | "Team419nrm1.java", |
| 1962 | "\n" + |
| 1963 | "public team class Team419nrm1 {\n" + |
| 1964 | " public class Role419nrm1 playedBy T419nrm1 {\n" + |
| 1965 | " String getValue(String arg) <- after String getValue(String arg);\n" + |
| 1966 | " }\n" + |
| 1967 | "}\n" + |
| 1968 | " \n" |
| 1969 | }, |
| 1970 | null); |
| 1971 | } |
| 1972 | |
| 1973 | // a role class callin-binds a non-existing role method |
| 1974 | // 4.1.9-otjld-nonexisting-role-method-2 |
| 1975 | public void test419_nonexistingRoleMethod2() { |
| 1976 | runNegativeTest( |
| 1977 | new String[] { |
| 1978 | "T419nrm2.java", |
| 1979 | "\n" + |
| 1980 | "public class T419nrm2 {\n" + |
| 1981 | " public String getValue(String arg) {\n" + |
| 1982 | " return arg;\n" + |
| 1983 | " }\n" + |
| 1984 | "}\n" + |
| 1985 | " \n", |
| 1986 | "Team419nrm2.java", |
| 1987 | "\n" + |
| 1988 | "public team class Team419nrm2 {\n" + |
| 1989 | "\n" + |
| 1990 | " public class Role419nrm2 playedBy T419nrm2 {\n" + |
| 1991 | " public String getValue(String arg) {\n" + |
| 1992 | " return arg;\n" + |
| 1993 | " }\n" + |
| 1994 | " getValue1 <- after getValue;\n" + |
| 1995 | " }\n" + |
| 1996 | "}\n" + |
| 1997 | " \n" |
| 1998 | }, |
| 1999 | null); |
| 2000 | } |
| 2001 | |
| 2002 | // a role class callin-binds a not-accessible role method |
| 2003 | // 4.1.9-otjld-nonexisting-role-method-3 |
| 2004 | public void test419_nonexistingRoleMethod3() { |
| 2005 | runNegativeTest( |
| 2006 | new String[] { |
| 2007 | "T419nrm3.java", |
| 2008 | "\n" + |
| 2009 | "public class T419nrm3 {\n" + |
| 2010 | " public void test(String arg) {}\n" + |
| 2011 | "}\n" + |
| 2012 | " \n", |
| 2013 | "Team419nrm3.java", |
| 2014 | "\n" + |
| 2015 | "public team class Team419nrm3 {\n" + |
| 2016 | " public class Role419nrm3_1 {\n" + |
| 2017 | " private void test() {}\n" + |
| 2018 | " }\n" + |
| 2019 | "\n" + |
| 2020 | " public class Role419nrm3_2 extends Role419nrm3_1 playedBy T419nrm3 {\n" + |
| 2021 | " void test() <- before void test(String arg);\n" + |
| 2022 | " }\n" + |
| 2023 | "}\n" + |
| 2024 | " \n" |
| 2025 | }, |
| 2026 | null); |
| 2027 | } |
| 2028 | |
| 2029 | // a role class callin-binds a non-protected role method |
| 2030 | // 4.1.9-otjld-nonexisting-role-method-4 |
| 2031 | public void test419_nonexistingRoleMethod4() { |
| 2032 | |
| 2033 | runConformTest( |
| 2034 | new String[] { |
| 2035 | "p2/Team419nrm4_2.java", |
| 2036 | "\n" + |
| 2037 | "package p2;\n" + |
| 2038 | "import base p1.T419nrm4;\n" + |
| 2039 | "public team class Team419nrm4_2 extends p1.Team419nrm4_1 {\n" + |
| 2040 | " public class Role419nrm4 playedBy T419nrm4 {\n" + |
| 2041 | " // check is indeed visible along implicit inheritance\n" + |
| 2042 | " check <- before test;\n" + |
| 2043 | " }\n" + |
| 2044 | " Team419nrm4_2() { activate(); }\n" + |
| 2045 | " public static void main(String[] args) {\n" + |
| 2046 | " new Team419nrm4_2();\n" + |
| 2047 | " (new p1.T419nrm4()).test();\n" + |
| 2048 | " }\n" + |
| 2049 | "}\n" + |
| 2050 | " \n", |
| 2051 | "p1/T419nrm4.java", |
| 2052 | "\n" + |
| 2053 | "package p1;\n" + |
| 2054 | "public class T419nrm4 {\n" + |
| 2055 | " public void test() {\n" + |
| 2056 | " System.out.print(\"K\");\n" + |
| 2057 | " }\n" + |
| 2058 | "}\n" + |
| 2059 | " \n", |
| 2060 | "p1/Team419nrm4_1.java", |
| 2061 | "\n" + |
| 2062 | "package p1;\n" + |
| 2063 | "public team class Team419nrm4_1 {\n" + |
| 2064 | " public class Role419nrm4 {\n" + |
| 2065 | " void check() {\n" + |
| 2066 | " System.out.print(\"O\");\n" + |
| 2067 | " }\n" + |
| 2068 | " }\n" + |
| 2069 | "}\n" + |
| 2070 | " \n" |
| 2071 | }, |
| 2072 | "OK"); |
| 2073 | } |
| 2074 | |
| 2075 | // a role class callin-binds a role method with a signature that has no return type whereas the actual role method has one |
| 2076 | // 4.1.9-otjld-nonexisting-role-method-5 |
| 2077 | public void test419_nonexistingRoleMethod5() { |
| 2078 | runNegativeTest( |
| 2079 | new String[] { |
| 2080 | "T419nrm5.java", |
| 2081 | "\n" + |
| 2082 | "public class T419nrm5 {\n" + |
| 2083 | " public void test() {}\n" + |
| 2084 | "}\n" + |
| 2085 | " \n", |
| 2086 | "Team419nrm5.java", |
| 2087 | "\n" + |
| 2088 | "public team class Team419nrm5 {\n" + |
| 2089 | "\n" + |
| 2090 | " public class Role419nrm5 playedBy T419nrm5 {\n" + |
| 2091 | " public String getValue() {\n" + |
| 2092 | " return null;\n" + |
| 2093 | " }\n" + |
| 2094 | " void getValue() <- before void test();\n" + |
| 2095 | " }\n" + |
| 2096 | "}\n" + |
| 2097 | " \n" |
| 2098 | }, |
| 2099 | null); |
| 2100 | } |
| 2101 | |
| 2102 | // a role class callin-binds a role method with a signature that has a return type whereas the actual role method has none |
| 2103 | // 4.1.9-otjld-nonexisting-role-method-6 |
| 2104 | public void test419_nonexistingRoleMethod6() { |
| 2105 | runNegativeTest( |
| 2106 | new String[] { |
| 2107 | "T419nrm6.java", |
| 2108 | "\n" + |
| 2109 | "public class T419nrm6 {\n" + |
| 2110 | " public String test() {\n" + |
| 2111 | " return null;\n" + |
| 2112 | " }\n" + |
| 2113 | "}\n" + |
| 2114 | " \n", |
| 2115 | "Team419nrm6.java", |
| 2116 | "\n" + |
| 2117 | "public team class Team419nrm6 {\n" + |
| 2118 | "\n" + |
| 2119 | " public class Role419nrm6 playedBy T419nrm6 {\n" + |
| 2120 | " protected void test() {}\n" + |
| 2121 | " String test() <- after String test();\n" + |
| 2122 | " }\n" + |
| 2123 | "}\n" + |
| 2124 | " \n" |
| 2125 | }, |
| 2126 | null); |
| 2127 | } |
| 2128 | |
| 2129 | // a role class callin-binds as 'replace' a role method with a signature that is different from the signature of the actual role method |
| 2130 | // 4.1.9-otjld-nonexisting-role-method-7 |
| 2131 | public void test419_nonexistingRoleMethod7() { |
| 2132 | runNegativeTest( |
| 2133 | new String[] { |
| 2134 | "T419nrm7.java", |
| 2135 | "\n" + |
| 2136 | "public class T419nrm7 {\n" + |
| 2137 | " public void test(String arg1, int arg2) {}\n" + |
| 2138 | "}\n" + |
| 2139 | " \n", |
| 2140 | "Team419nrm7.java", |
| 2141 | "\n" + |
| 2142 | "public team class Team419nrm7 {\n" + |
| 2143 | "\n" + |
| 2144 | " public class Role419nrm7 playedBy T419nrm7 {\n" + |
| 2145 | " callin void test(String arg1, int arg2) {\n" + |
| 2146 | " base.test(arg1, arg2);\n" + |
| 2147 | " }\n" + |
| 2148 | " void test(String arg1, short arg2) <- replace void test(String arg1, int arg2);\n" + |
| 2149 | " }\n" + |
| 2150 | "}\n" + |
| 2151 | " \n" |
| 2152 | }, |
| 2153 | null); |
| 2154 | } |
| 2155 | |
| 2156 | // a role class callin-binds a role method with a signature that has less parameters than the real role method |
| 2157 | // 4.1.9-otjld-nonexisting-role-method-8 |
| 2158 | public void test419_nonexistingRoleMethod8() { |
| 2159 | runNegativeTest( |
| 2160 | new String[] { |
| 2161 | "T419nrm8.java", |
| 2162 | "\n" + |
| 2163 | "public class T419nrm8 {\n" + |
| 2164 | " public void test() {}\n" + |
| 2165 | "}\n" + |
| 2166 | " \n", |
| 2167 | "Team419nrm8.java", |
| 2168 | "\n" + |
| 2169 | "public team class Team419nrm8 {\n" + |
| 2170 | "\n" + |
| 2171 | " public class Role419nrm8 playedBy T419nrm8 {\n" + |
| 2172 | " public void test(String arg) {}\n" + |
| 2173 | " void test() <- after void test();\n" + |
| 2174 | " }\n" + |
| 2175 | "}\n" + |
| 2176 | " \n" |
| 2177 | }, |
| 2178 | null); |
| 2179 | } |
| 2180 | |
| 2181 | // a role class callin-binds a role method with a signature that has more parameters than the real role method |
| 2182 | // 4.1.9-otjld-nonexisting-role-method-9 |
| 2183 | public void test419_nonexistingRoleMethod9() { |
| 2184 | runNegativeTest( |
| 2185 | new String[] { |
| 2186 | "T419nrm9.java", |
| 2187 | "\n" + |
| 2188 | "public class T419nrm9 {\n" + |
| 2189 | " public void test(String arg) {}\n" + |
| 2190 | "}\n" + |
| 2191 | " \n", |
| 2192 | "Team419nrm9.java", |
| 2193 | "\n" + |
| 2194 | "public team class Team419nrm9 {\n" + |
| 2195 | "\n" + |
| 2196 | " public class Role419nrm9 playedBy T419nrm9 {\n" + |
| 2197 | " public void test1() {}\n" + |
| 2198 | " void test1(String arg) <- after void test(String arg);\n" + |
| 2199 | " }\n" + |
| 2200 | "}\n" + |
| 2201 | " \n" |
| 2202 | }, |
| 2203 | null); |
| 2204 | } |
| 2205 | |
| 2206 | // a callin-binding refers to a base method instead of a role method |
| 2207 | // 4.1.10-otjld-callin-binding-between-base-methods |
| 2208 | public void test4110_callinBindingBetweenBaseMethods() { |
| 2209 | runNegativeTest( |
| 2210 | new String[] { |
| 2211 | "T4110cbbbm.java", |
| 2212 | "\n" + |
| 2213 | "public class T4110cbbbm {\n" + |
| 2214 | " public void test() {}\n" + |
| 2215 | " public void doSomething() {}\n" + |
| 2216 | "}\n" + |
| 2217 | " \n", |
| 2218 | "Team4110cbbbm.java", |
| 2219 | "\n" + |
| 2220 | "public team class Team4110cbbbm {\n" + |
| 2221 | "\n" + |
| 2222 | " public class Role4110cbbbm playedBy T4110cbbbm {\n" + |
| 2223 | " public void test() {}\n" + |
| 2224 | " doSomething <- before test;\n" + |
| 2225 | " }\n" + |
| 2226 | "}\n" + |
| 2227 | " \n" |
| 2228 | }, |
| 2229 | null); |
| 2230 | } |
| 2231 | |
| 2232 | // a role method is callin-bound as 'before' to multiple base methods |
| 2233 | // 4.1.12-otjld-callin-binding-multiple-base-methods-1 |
| 2234 | public void test4112_callinBindingMultipleBaseMethods1() { |
| 2235 | |
| 2236 | runConformTest( |
| 2237 | new String[] { |
| 2238 | "T4112cbmbm1Main.java", |
| 2239 | "\n" + |
| 2240 | "public class T4112cbmbm1Main {\n" + |
| 2241 | " public static void main(String[] args) {\n" + |
| 2242 | " Team4112cbmbm1 t = new Team4112cbmbm1();\n" + |
| 2243 | "\n" + |
| 2244 | " t.activate();\n" + |
| 2245 | "\n" + |
| 2246 | " T4112cbmbm1_3 o = new T4112cbmbm1_3();\n" + |
| 2247 | "\n" + |
| 2248 | " T4112cbmbm1_1.addValue(o.getValue(\"a\"));\n" + |
| 2249 | " o.test(\"b\");\n" + |
| 2250 | "\n" + |
| 2251 | " System.out.print(T4112cbmbm1_1.getValue());\n" + |
| 2252 | " }\n" + |
| 2253 | "}\n" + |
| 2254 | " \n", |
| 2255 | "T4112cbmbm1_1.java", |
| 2256 | "\n" + |
| 2257 | "public class T4112cbmbm1_1 {\n" + |
| 2258 | " private static String value = \"\";\n" + |
| 2259 | " public static void addValue(String arg) {\n" + |
| 2260 | " value += \"|\"+arg+\"|\";\n" + |
| 2261 | " }\n" + |
| 2262 | " public static String getValue() {\n" + |
| 2263 | " return value;\n" + |
| 2264 | " }\n" + |
| 2265 | "}\n" + |
| 2266 | " \n", |
| 2267 | "T4112cbmbm1_2.java", |
| 2268 | "\n" + |
| 2269 | "public class T4112cbmbm1_2 {\n" + |
| 2270 | " public String getValue(String arg) {\n" + |
| 2271 | " return arg;\n" + |
| 2272 | " }\n" + |
| 2273 | "}\n" + |
| 2274 | " \n", |
| 2275 | "T4112cbmbm1_3.java", |
| 2276 | "\n" + |
| 2277 | "public class T4112cbmbm1_3 extends T4112cbmbm1_2 {\n" + |
| 2278 | " public void test(String arg) {\n" + |
| 2279 | " T4112cbmbm1_1.addValue(arg);\n" + |
| 2280 | " }\n" + |
| 2281 | "}\n" + |
| 2282 | " \n", |
| 2283 | "Team4112cbmbm1.java", |
| 2284 | "\n" + |
| 2285 | "public team class Team4112cbmbm1 {\n" + |
| 2286 | " public class Role4112cbmbm1_1 playedBy T4112cbmbm1_2 {\n" + |
| 2287 | " private int counter = 0;\n" + |
| 2288 | " protected void test(String arg) {\n" + |
| 2289 | " T4112cbmbm1_1.addValue(String.valueOf(++counter)+\":\"+arg);\n" + |
| 2290 | " }\n" + |
| 2291 | " }\n" + |
| 2292 | " public class Role4112cbmbm1_2 extends Role4112cbmbm1_1 playedBy T4112cbmbm1_3 {\n" + |
| 2293 | " test <- before test, getValue;\n" + |
| 2294 | " }\n" + |
| 2295 | "}\n" + |
| 2296 | " \n" |
| 2297 | }, |
| 2298 | "|1:a||a||2:b||b|"); |
| 2299 | } |
| 2300 | |
| 2301 | // a role method is callin-bound as 'after' to multiple base methods |
| 2302 | // 4.1.12-otjld-callin-binding-multiple-base-methods-2 |
| 2303 | public void test4112_callinBindingMultipleBaseMethods2() { |
| 2304 | |
| 2305 | runConformTest( |
| 2306 | new String[] { |
| 2307 | "T4112cbmbm2Main.java", |
| 2308 | "\n" + |
| 2309 | "public class T4112cbmbm2Main {\n" + |
| 2310 | " public static void main(String[] args) {\n" + |
| 2311 | " Team4112cbmbm2_2 t = new Team4112cbmbm2_2();\n" + |
| 2312 | "\n" + |
| 2313 | " within (t) {\n" + |
| 2314 | " T4112cbmbm2_4 o = new T4112cbmbm2_4();\n" + |
| 2315 | " \n" + |
| 2316 | " T4112cbmbm2_1.addValue(o.getValue(\"a\").toString());\n" + |
| 2317 | " T4112cbmbm2_1.addValue(o.test2(\"c\", \"d\").toString());\n" + |
| 2318 | " T4112cbmbm2_1.addValue(o.test1(\"b\").toString());\n" + |
| 2319 | " }\n" + |
| 2320 | "\n" + |
| 2321 | " System.out.print(T4112cbmbm2_1.getValue());\n" + |
| 2322 | " }\n" + |
| 2323 | "}\n" + |
| 2324 | " \n", |
| 2325 | "T4112cbmbm2_1.java", |
| 2326 | "\n" + |
| 2327 | "public class T4112cbmbm2_1 {\n" + |
| 2328 | " private static String value = \"\";\n" + |
| 2329 | " public static void addValue(String arg) {\n" + |
| 2330 | " value += \"|\"+arg+\"|\";\n" + |
| 2331 | " }\n" + |
| 2332 | " public static String getValue() {\n" + |
| 2333 | " return value;\n" + |
| 2334 | " }\n" + |
| 2335 | "}\n" + |
| 2336 | " \n", |
| 2337 | "T4112cbmbm2_2.java", |
| 2338 | "\n" + |
| 2339 | "public class T4112cbmbm2_2 {\n" + |
| 2340 | " public Object getValue(String arg) {\n" + |
| 2341 | " T4112cbmbm2_1.addValue(arg);\n" + |
| 2342 | " return arg;\n" + |
| 2343 | " }\n" + |
| 2344 | "}\n" + |
| 2345 | " \n", |
| 2346 | "T4112cbmbm2_3.java", |
| 2347 | "\n" + |
| 2348 | "public class T4112cbmbm2_3 extends T4112cbmbm2_2 {}\n" + |
| 2349 | " \n", |
| 2350 | "T4112cbmbm2_4.java", |
| 2351 | "\n" + |
| 2352 | "public class T4112cbmbm2_4 extends T4112cbmbm2_3 {\n" + |
| 2353 | " public String test1(String arg) {\n" + |
| 2354 | " T4112cbmbm2_1.addValue(arg);\n" + |
| 2355 | " return arg;\n" + |
| 2356 | " }\n" + |
| 2357 | " public Object test2(String arg1, String arg2) {\n" + |
| 2358 | " T4112cbmbm2_1.addValue(arg1 + arg2);\n" + |
| 2359 | " return arg1 + arg2;\n" + |
| 2360 | " }\n" + |
| 2361 | "}\n" + |
| 2362 | " \n", |
| 2363 | "Team4112cbmbm2_1.java", |
| 2364 | "\n" + |
| 2365 | "public team class Team4112cbmbm2_1 {\n" + |
| 2366 | " public class Role4112cbmbm2 {\n" + |
| 2367 | " private int counter = 0;\n" + |
| 2368 | " Object test(String arg) {\n" + |
| 2369 | " T4112cbmbm2_1.addValue(String.valueOf(++counter)+\":\"+arg);\n" + |
| 2370 | " return null;\n" + |
| 2371 | " }\n" + |
| 2372 | " }\n" + |
| 2373 | "}\n" + |
| 2374 | " \n", |
| 2375 | "Team4112cbmbm2_2.java", |
| 2376 | "\n" + |
| 2377 | "public team class Team4112cbmbm2_2 extends Team4112cbmbm2_1 {\n" + |
| 2378 | " public class Role4112cbmbm2 playedBy T4112cbmbm2_4 {\n" + |
| 2379 | " Object test(String arg) <- after String test1(String arg),\n" + |
| 2380 | " Object test2(String arg1, String arg2),\n" + |
| 2381 | " Object getValue(String arg);\n" + |
| 2382 | " }\n" + |
| 2383 | "}\n" + |
| 2384 | " \n" |
| 2385 | }, |
| 2386 | "|a||1:a||a||cd||2:c||cd||b||3:b||b|"); |
| 2387 | } |
| 2388 | |
| 2389 | // a role method is callin-bound as 'replace' to multiple base methods |
| 2390 | // 4.1.12-otjld-callin-binding-multiple-base-methods-3 |
| 2391 | public void test4112_callinBindingMultipleBaseMethods3() { |
| 2392 | |
| 2393 | runConformTest( |
| 2394 | new String[] { |
| 2395 | "T4112cbmbm3Main.java", |
| 2396 | "\n" + |
| 2397 | "public class T4112cbmbm3Main {\n" + |
| 2398 | " public static void main(String[] args) {\n" + |
| 2399 | " Team4112cbmbm3 t = new Team4112cbmbm3();\n" + |
| 2400 | "\n" + |
| 2401 | " t.activate();\n" + |
| 2402 | "\n" + |
| 2403 | " T4112cbmbm3_2 o = new T4112cbmbm3_2();\n" + |
| 2404 | "\n" + |
| 2405 | " T4112cbmbm3_1.addValue(o.test1(1));\n" + |
| 2406 | " o.test2(2, 3);\n" + |
| 2407 | "\n" + |
| 2408 | " System.out.print(T4112cbmbm3_1.getValue());\n" + |
| 2409 | " }\n" + |
| 2410 | "}\n" + |
| 2411 | " \n", |
| 2412 | "T4112cbmbm3_1.java", |
| 2413 | "\n" + |
| 2414 | "public class T4112cbmbm3_1 {\n" + |
| 2415 | " private static String value = \"\";\n" + |
| 2416 | " public static void addValue(long arg) {\n" + |
| 2417 | " value += \"|\"+arg+\"|\";\n" + |
| 2418 | " }\n" + |
| 2419 | " public static void addValue(String arg) {\n" + |
| 2420 | " value += \"|\"+arg+\"|\";\n" + |
| 2421 | " }\n" + |
| 2422 | " public static String getValue() {\n" + |
| 2423 | " return value;\n" + |
| 2424 | " }\n" + |
| 2425 | "}\n" + |
| 2426 | " \n", |
| 2427 | "T4112cbmbm3_2.java", |
| 2428 | "\n" + |
| 2429 | "public class T4112cbmbm3_2 {\n" + |
| 2430 | " public int test1(int arg) {\n" + |
| 2431 | " return arg - 1;\n" + |
| 2432 | " }\n" + |
| 2433 | " public void test2(int arg1, int arg2) {\n" + |
| 2434 | " T4112cbmbm3_1.addValue(arg1 * arg2);\n" + |
| 2435 | " }\n" + |
| 2436 | "}\n" + |
| 2437 | " \n", |
| 2438 | "Team4112cbmbm3.java", |
| 2439 | "\n" + |
| 2440 | "public team class Team4112cbmbm3 {\n" + |
| 2441 | " public class Role4112cbmbm3 playedBy T4112cbmbm3_2 {\n" + |
| 2442 | " private int counter = 0;\n" + |
| 2443 | " callin void test(int arg) {\n" + |
| 2444 | " T4112cbmbm3_1.addValue(String.valueOf(++counter)+\":\"+arg);\n" + |
| 2445 | " base.test(0);\n" + |
| 2446 | " }\n" + |
| 2447 | " // fragile binding -> warning\n" + |
| 2448 | " void test(int arg) <- replace int test1(int arg), void test2(int arg1, int arg2);\n" + |
| 2449 | " }\n" + |
| 2450 | "}\n" + |
| 2451 | " \n" |
| 2452 | }, |
| 2453 | "|1:1||-1||2:2||0|"); |
| 2454 | // FIXME expect this warning |
| 2455 | } |
| 2456 | |
| 2457 | |
| 2458 | // a role method is callin-bound as 'replace' to multiple base methods - this requires exact signature matches |
| 2459 | // 4.1.12-otjld-callin-binding-multiple-base-methods-5 |
| 2460 | public void test4112_callinBindingMultipleBaseMethods5() { |
| 2461 | |
| 2462 | runConformTest( |
| 2463 | new String[] { |
| 2464 | "T4112cbmbm5Main.java", |
| 2465 | "\n" + |
| 2466 | "public class T4112cbmbm5Main {\n" + |
| 2467 | " public static void main(String[] args) {\n" + |
| 2468 | " Team4112cbmbm5_2 t = new Team4112cbmbm5_2();\n" + |
| 2469 | "\n" + |
| 2470 | " within (t) {\n" + |
| 2471 | " T4112cbmbm5_4 o = new T4112cbmbm5_4();\n" + |
| 2472 | "\n" + |
| 2473 | " T4112cbmbm5_1.addValue(o.test3(\"a\",\"X\").toString());\n" + |
| 2474 | " T4112cbmbm5_1.addValue(o.test2(\"c\",\"Y\").toString());\n" + |
| 2475 | " T4112cbmbm5_1.addValue(o.test1(\"b\").toString());\n" + |
| 2476 | " }\n" + |
| 2477 | "\n" + |
| 2478 | " System.out.print(T4112cbmbm5_1.getValue());\n" + |
| 2479 | " }\n" + |
| 2480 | "}\n" + |
| 2481 | " \n", |
| 2482 | "T4112cbmbm5_1.java", |
| 2483 | "\n" + |
| 2484 | "public class T4112cbmbm5_1 {\n" + |
| 2485 | " private static String value = \"\";\n" + |
| 2486 | " public static void addValues(String arg1, String arg2) {\n" + |
| 2487 | " value += \"|\"+arg1+\"#\"+arg2+\"|\";\n" + |
| 2488 | " }\n" + |
| 2489 | " public static void addValue(String arg) {\n" + |
| 2490 | " value += \"|\"+arg+\"|\";\n" + |
| 2491 | " }\n" + |
| 2492 | " public static String getValue() {\n" + |
| 2493 | " return value;\n" + |
| 2494 | " }\n" + |
| 2495 | "}\n" + |
| 2496 | " \n", |
| 2497 | "T4112cbmbm5_2.java", |
| 2498 | "\n" + |
| 2499 | "public class T4112cbmbm5_2 {\n" + |
| 2500 | " public Object test1(Object arg) {\n" + |
| 2501 | " T4112cbmbm5_1.addValue(arg.toString());\n" + |
| 2502 | " return arg.toString();\n" + |
| 2503 | " }\n" + |
| 2504 | "}\n" + |
| 2505 | " \n", |
| 2506 | "T4112cbmbm5_3.java", |
| 2507 | "\n" + |
| 2508 | "public class T4112cbmbm5_3 extends T4112cbmbm5_2 {\n" + |
| 2509 | " Object test2(Object arg, String str) {\n" + |
| 2510 | " T4112cbmbm5_1.addValues(arg.toString(), \"->\"+str);\n" + |
| 2511 | " return arg;\n" + |
| 2512 | " }\n" + |
| 2513 | "}\n" + |
| 2514 | " \n", |
| 2515 | "T4112cbmbm5_4.java", |
| 2516 | "\n" + |
| 2517 | "public class T4112cbmbm5_4 extends T4112cbmbm5_3 {\n" + |
| 2518 | " Object test3(String arg, Object o) {\n" + |
| 2519 | " T4112cbmbm5_1.addValues(arg, o.toString());\n" + |
| 2520 | " return arg;\n" + |
| 2521 | " }\n" + |
| 2522 | "}\n" + |
| 2523 | " \n", |
| 2524 | "Team4112cbmbm5_1.java", |
| 2525 | "\n" + |
| 2526 | "public team class Team4112cbmbm5_1 {\n" + |
| 2527 | " public class Role4112cbmbm5_1 playedBy T4112cbmbm5_2 {\n" + |
| 2528 | " private int counter = 0;\n" + |
| 2529 | " callin Object test(Object arg) {\n" + |
| 2530 | " T4112cbmbm5_1.addValue(String.valueOf(++counter)+\":\"+arg.toString());\n" + |
| 2531 | " return base.test(\"-\");\n" + |
| 2532 | " }\n" + |
| 2533 | " }\n" + |
| 2534 | "\n" + |
| 2535 | "}\n" + |
| 2536 | " \n", |
| 2537 | "Team4112cbmbm5_2.java", |
| 2538 | "\n" + |
| 2539 | "public team class Team4112cbmbm5_2 extends Team4112cbmbm5_1 {\n" + |
| 2540 | " public class Role4112cbmbm5_2 extends Role4112cbmbm5_1 playedBy T4112cbmbm5_4 {\n" + |
| 2541 | " test <- replace test1, test2;\n" + |
| 2542 | " Object test(Object o1) <- replace Object test3(String s1, Object o2) with {\n" + |
| 2543 | " o1 <- o2,\n" + |
| 2544 | " result -> result\n" + |
| 2545 | " }\n" + |
| 2546 | " }\n" + |
| 2547 | "}\n" + |
| 2548 | " \n" |
| 2549 | }, |
| 2550 | "|1:X||a#-||a||2:c||-#->Y||-||3:b||-||-|"); |
| 2551 | // FIXME expect this warning |
| 2552 | } |
| 2553 | |
| 2554 | // a role method is callin-bound as 'replace' where matching would require (two-way) polymorphism |
| 2555 | // 4.1.12-otjld-callin-binding-multiple-base-methods-6 |
| 2556 | public void test4112_callinBindingMultipleBaseMethods6() { |
| 2557 | runNegativeTest( |
| 2558 | new String[] { |
| 2559 | "T4112cbmbm6_1.java", |
| 2560 | "\n" + |
| 2561 | "public class T4112cbmbm6_1 {\n" + |
| 2562 | " private static String value = \"\";\n" + |
| 2563 | " public static void addValue(String arg) {\n" + |
| 2564 | " value += \"|\"+arg+\"|\";\n" + |
| 2565 | " }\n" + |
| 2566 | " public static String getValue() {\n" + |
| 2567 | " return value;\n" + |
| 2568 | " }\n" + |
| 2569 | "}\n" + |
| 2570 | " \n", |
| 2571 | "T4112cbmbm6_2.java", |
| 2572 | "\n" + |
| 2573 | "public class T4112cbmbm6_2 {\n" + |
| 2574 | " public String test1(Object arg) {\n" + |
| 2575 | " T4112cbmbm6_1.addValue(arg.toString());\n" + |
| 2576 | " return arg.toString();\n" + |
| 2577 | " }\n" + |
| 2578 | "}\n" + |
| 2579 | " \n", |
| 2580 | "T4112cbmbm6_3.java", |
| 2581 | "\n" + |
| 2582 | "public class T4112cbmbm6_3 extends T4112cbmbm6_2 {\n" + |
| 2583 | " Object test2(Object arg) {\n" + |
| 2584 | " T4112cbmbm6_1.addValue(arg.toString());\n" + |
| 2585 | " return arg;\n" + |
| 2586 | " }\n" + |
| 2587 | "}\n" + |
| 2588 | " \n", |
| 2589 | "Team4112cbmbm6_1.java", |
| 2590 | "\n" + |
| 2591 | "public team class Team4112cbmbm6_1 {\n" + |
| 2592 | " public class Role4112cbmbm6_1 playedBy T4112cbmbm6_2 {\n" + |
| 2593 | " private int counter = 0;\n" + |
| 2594 | " // no base call\n" + |
| 2595 | " callin String test(Object arg) {\n" + |
| 2596 | " T4112cbmbm6_1.addValue(String.valueOf(++counter)+\":\"+arg.toString());\n" + |
| 2597 | " return \"-\";\n" + |
| 2598 | " }\n" + |
| 2599 | " }\n" + |
| 2600 | "\n" + |
| 2601 | "}\n" + |
| 2602 | " \n", |
| 2603 | "Team4112cbmbm6_2.java", |
| 2604 | "\n" + |
| 2605 | "public team class Team4112cbmbm6_2 extends Team4112cbmbm6_1 {\n" + |
| 2606 | " public class Role4112cbmbm6_2 extends Role4112cbmbm6_1 playedBy T4112cbmbm6_3 {\n" + |
| 2607 | " test <- replace test2;\n" + |
| 2608 | " }\n" + |
| 2609 | "}\n" + |
| 2610 | " \n" |
| 2611 | }, |
| 2612 | null); |
| 2613 | // FIXME expect this warning |
| 2614 | } |
| 2615 | |
| 2616 | // a role method without a return type is callin-bound as 'before' to a base method with a return type |
| 2617 | // 4.1.13-otjld-base-return-value-1 |
| 2618 | public void test4113_baseReturnValue1() { |
| 2619 | |
| 2620 | runConformTest( |
| 2621 | new String[] { |
| 2622 | "T4113brv1Main.java", |
| 2623 | "\n" + |
| 2624 | "public class T4113brv1Main {\n" + |
| 2625 | " public static void main(String[] args) {\n" + |
| 2626 | " Team4113brv1 t = new Team4113brv1();\n" + |
| 2627 | "\n" + |
| 2628 | " within (t) {\n" + |
| 2629 | " T4113brv1 o = new T4113brv1();\n" + |
| 2630 | "\n" + |
| 2631 | " System.out.print(o.getValue());\n" + |
| 2632 | " }\n" + |
| 2633 | " }\n" + |
| 2634 | "}\n" + |
| 2635 | " \n", |
| 2636 | "T4113brv1.java", |
| 2637 | "\n" + |
| 2638 | "public class T4113brv1 {\n" + |
| 2639 | " public static String value = null;\n" + |
| 2640 | " public String getValue() {\n" + |
| 2641 | " return value;\n" + |
| 2642 | " }\n" + |
| 2643 | "}\n" + |
| 2644 | " \n", |
| 2645 | "Team4113brv1.java", |
| 2646 | "\n" + |
| 2647 | "public team class Team4113brv1 {\n" + |
| 2648 | "\n" + |
| 2649 | " public class Role4113brv1 playedBy T4113brv1 {\n" + |
| 2650 | " public void test() {\n" + |
| 2651 | " T4113brv1.value = \"OK\";\n" + |
| 2652 | " }\n" + |
| 2653 | " void test() <- before String getValue();\n" + |
| 2654 | " }\n" + |
| 2655 | "}\n" + |
| 2656 | " \n" |
| 2657 | }, |
| 2658 | "OK"); |
| 2659 | } |
| 2660 | |
| 2661 | // a role method without a return type is callin-bound as 'after' to a base method with a return type |
| 2662 | // 4.1.13-otjld-base-return-value-2 |
| 2663 | public void test4113_baseReturnValue2() { |
| 2664 | |
| 2665 | runConformTest( |
| 2666 | new String[] { |
| 2667 | "T4113brv2Main.java", |
| 2668 | "\n" + |
| 2669 | "public class T4113brv2Main {\n" + |
| 2670 | " public static void main(String[] args) {\n" + |
| 2671 | " Team4113brv2 t = new Team4113brv2();\n" + |
| 2672 | "\n" + |
| 2673 | " within (t) {\n" + |
| 2674 | " T4113brv2 o = new T4113brv2();\n" + |
| 2675 | "\n" + |
| 2676 | " System.out.print(o.getValue());\n" + |
| 2677 | " }\n" + |
| 2678 | " }\n" + |
| 2679 | "}\n" + |
| 2680 | " \n", |
| 2681 | "T4113brv2.java", |
| 2682 | "\n" + |
| 2683 | "public class T4113brv2 {\n" + |
| 2684 | " public static String value = \"OK\";\n" + |
| 2685 | " public String getValue() {\n" + |
| 2686 | " return value;\n" + |
| 2687 | " }\n" + |
| 2688 | "}\n" + |
| 2689 | " \n", |
| 2690 | "Team4113brv2.java", |
| 2691 | "\n" + |
| 2692 | "public team class Team4113brv2 {\n" + |
| 2693 | "\n" + |
| 2694 | " public class Role4113brv2 playedBy T4113brv2 {\n" + |
| 2695 | " public void test() {\n" + |
| 2696 | " T4113brv2.value = \"NOTOK\";\n" + |
| 2697 | " }\n" + |
| 2698 | " test <- after getValue;\n" + |
| 2699 | " }\n" + |
| 2700 | "}\n" + |
| 2701 | " \n" |
| 2702 | }, |
| 2703 | "OK"); |
| 2704 | } |
| 2705 | |
| 2706 | // a role method without a return type is callin-bound as 'replace' to a base method with a return type , "return" must be translated to return null |
| 2707 | // 4.1.13-otjld-base-return-value-3 |
| 2708 | public void test4113_baseReturnValue3() { |
| 2709 | |
| 2710 | runConformTest( |
| 2711 | new String[] { |
| 2712 | "T4113brv3Main.java", |
| 2713 | "\n" + |
| 2714 | "public class T4113brv3Main {\n" + |
| 2715 | " public static void main(String[] args) {\n" + |
| 2716 | " Team4113brv3 t = new Team4113brv3();\n" + |
| 2717 | "\n" + |
| 2718 | " within (t) {\n" + |
| 2719 | " T4113brv3 o = new T4113brv3();\n" + |
| 2720 | "\n" + |
| 2721 | " System.out.print(o.getValue());\n" + |
| 2722 | " }\n" + |
| 2723 | " }\n" + |
| 2724 | "}\n" + |
| 2725 | " \n", |
| 2726 | "T4113brv3.java", |
| 2727 | "\n" + |
| 2728 | "public class T4113brv3 {\n" + |
| 2729 | " public static String value = \"WRONG\";\n" + |
| 2730 | " public String getValue() {\n" + |
| 2731 | " return value;\n" + |
| 2732 | " }\n" + |
| 2733 | "}\n" + |
| 2734 | " \n", |
| 2735 | "Team4113brv3.java", |
| 2736 | "\n" + |
| 2737 | "public team class Team4113brv3 {\n" + |
| 2738 | "\n" + |
| 2739 | " public class Role4113brv3 playedBy T4113brv3 {\n" + |
| 2740 | " callin void test(String val) {\n" + |
| 2741 | " T4113brv3.value = \"OK\";\n" + |
| 2742 | " if (\"NOTOK\".equals(val)) {\n" + |
| 2743 | " base.test(val);\n" + |
| 2744 | " return;\n" + |
| 2745 | " } else {\n" + |
| 2746 | " base.test(\"even worse\");\n" + |
| 2747 | " }\n" + |
| 2748 | " System.out.print(\"shouldn't reach here\");\n" + |
| 2749 | " }\n" + |
| 2750 | " void test(String v) <- replace String getValue()\n" + |
| 2751 | " with { v <- \"NOTOK\" }\n" + |
| 2752 | " }\n" + |
| 2753 | "}\n" + |
| 2754 | " \n" |
| 2755 | }, |
| 2756 | "OK"); |
| 2757 | } |
| 2758 | |
| 2759 | // a role method without a return type is callin-bound as 'replace' to a base method with a base return type |
| 2760 | // 4.1.13-otjld-base-return-value-4 |
| 2761 | public void test4113_baseReturnValue4() { |
| 2762 | |
| 2763 | runConformTest( |
| 2764 | new String[] { |
| 2765 | "T4113brv4Main.java", |
| 2766 | "\n" + |
| 2767 | "public class T4113brv4Main {\n" + |
| 2768 | " public static void main(String[] args) {\n" + |
| 2769 | " Team4113brv4 t = new Team4113brv4();\n" + |
| 2770 | "\n" + |
| 2771 | " within (t) {\n" + |
| 2772 | " T4113brv4 o = new T4113brv4();\n" + |
| 2773 | "\n" + |
| 2774 | " System.out.print(o.getValue());\n" + |
| 2775 | " }\n" + |
| 2776 | " }\n" + |
| 2777 | "}\n" + |
| 2778 | " \n", |
| 2779 | "T4113brv4.java", |
| 2780 | "\n" + |
| 2781 | "public class T4113brv4 {\n" + |
| 2782 | " public static char value = '?';\n" + |
| 2783 | " public char getValue() {\n" + |
| 2784 | " return value;\n" + |
| 2785 | " }\n" + |
| 2786 | "}\n" + |
| 2787 | " \n", |
| 2788 | "Team4113brv4.java", |
| 2789 | "\n" + |
| 2790 | "public team class Team4113brv4 {\n" + |
| 2791 | "\n" + |
| 2792 | " public class Role4113brv4 playedBy T4113brv4 {\n" + |
| 2793 | " callin void test(char val) {\n" + |
| 2794 | " T4113brv4.value = '!';\n" + |
| 2795 | " if (val == '#') {\n" + |
| 2796 | " base.test(val);\n" + |
| 2797 | " return;\n" + |
| 2798 | " } else {\n" + |
| 2799 | " base.test('@');\n" + |
| 2800 | " }\n" + |
| 2801 | " System.out.print(\"shouldn't reach here\");\n" + |
| 2802 | " }\n" + |
| 2803 | " void test(char v) <- replace char getValue()\n" + |
| 2804 | " with { v <- '#' }\n" + |
| 2805 | " }\n" + |
| 2806 | "}\n" + |
| 2807 | " \n" |
| 2808 | }, |
| 2809 | "!"); |
| 2810 | } |
| 2811 | |
| 2812 | // a role method a base return type is callin-bound as 'replace', testing boxing/unboxing in translated code |
| 2813 | // 4.1.13-otjld-base-return-value-5 |
| 2814 | public void test4113_baseReturnValue5() { |
| 2815 | |
| 2816 | runConformTest( |
| 2817 | new String[] { |
| 2818 | "T4113brv5Main.java", |
| 2819 | "\n" + |
| 2820 | "public class T4113brv5Main {\n" + |
| 2821 | " public static void main(String[] args) {\n" + |
| 2822 | " Team4113brv5 t = new Team4113brv5();\n" + |
| 2823 | "\n" + |
| 2824 | " within (t) {\n" + |
| 2825 | " T4113brv5 o = new T4113brv5();\n" + |
| 2826 | "\n" + |
| 2827 | " System.out.print(o.getValue());\n" + |
| 2828 | " }\n" + |
| 2829 | " }\n" + |
| 2830 | "}\n" + |
| 2831 | " \n", |
| 2832 | "T4113brv5.java", |
| 2833 | "\n" + |
| 2834 | "public class T4113brv5 {\n" + |
| 2835 | " public static char value = '?';\n" + |
| 2836 | " public char getValue() {\n" + |
| 2837 | " return value;\n" + |
| 2838 | " }\n" + |
| 2839 | "}\n" + |
| 2840 | " \n", |
| 2841 | "Team4113brv5.java", |
| 2842 | "\n" + |
| 2843 | "public team class Team4113brv5 {\n" + |
| 2844 | "\n" + |
| 2845 | " public class Role4113brv5 playedBy T4113brv5 {\n" + |
| 2846 | " callin char test(char val) {\n" + |
| 2847 | " T4113brv5.value = '!';\n" + |
| 2848 | " if (val == '#') {\n" + |
| 2849 | " char ignore= base.test(val);\n" + |
| 2850 | " return '$';\n" + |
| 2851 | " } else {\n" + |
| 2852 | " char ignore2= base.test('@');\n" + |
| 2853 | " }\n" + |
| 2854 | " System.out.print(\"shouldn't reach here\");\n" + |
| 2855 | " return '-';\n" + |
| 2856 | " }\n" + |
| 2857 | " char test(char v) <- replace char getValue()\n" + |
| 2858 | " with { v <- '#' }\n" + |
| 2859 | " }\n" + |
| 2860 | "}\n" + |
| 2861 | " \n" |
| 2862 | }, |
| 2863 | "$"); |
| 2864 | } |
| 2865 | |
| 2866 | // a role method a base return type is callin-bound as 'replace', testing boxing/unboxing in translated code: type error |
| 2867 | // 4.1.13-otjld-base-return-value-6 |
| 2868 | public void test4113_baseReturnValue6() { |
| 2869 | runNegativeTestMatching( |
| 2870 | new String[] { |
| 2871 | "Team4113brv6.java", |
| 2872 | "\n" + |
| 2873 | "public team class Team4113brv6 {\n" + |
| 2874 | "\n" + |
| 2875 | " public class Role4113brv6 playedBy T4113brv6 {\n" + |
| 2876 | " callin char test(char val) {\n" + |
| 2877 | " T4113brv6.value = '!';\n" + |
| 2878 | " if (val == '#') {\n" + |
| 2879 | " char ignore= base.test(val);\n" + |
| 2880 | " return 3;\n" + |
| 2881 | " } else {\n" + |
| 2882 | " char ignore2= base.test('@');\n" + |
| 2883 | " }\n" + |
| 2884 | " System.out.print(\"shouldn't reach here\");\n" + |
| 2885 | " return '-';\n" + |
| 2886 | " }\n" + |
| 2887 | " char test(char v) <- replace char getValue()\n" + |
| 2888 | " with { v <- '#' }\n" + |
| 2889 | " }\n" + |
| 2890 | "}\n" + |
| 2891 | " \n", |
| 2892 | "T4113brv6.java", |
| 2893 | "\n" + |
| 2894 | "public class T4113brv6 {\n" + |
| 2895 | " public static char value = '?';\n" + |
| 2896 | " public char getValue() {\n" + |
| 2897 | " return value;\n" + |
| 2898 | " }\n" + |
| 2899 | "}\n" + |
| 2900 | " \n" |
| 2901 | }, |
| 2902 | "cannot convert"); |
| 2903 | } |
| 2904 | |
| 2905 | // a role method with a return type is callin-bound as 'before' to a base method without a return type |
| 2906 | // 4.1.15-otjld-ignore-role-method-return-value-1 |
| 2907 | public void test4115_ignoreRoleMethodReturnValue1() { |
| 2908 | |
| 2909 | runConformTest( |
| 2910 | new String[] { |
| 2911 | "T4115irmrv1Main.java", |
| 2912 | "\n" + |
| 2913 | "public class T4115irmrv1Main {\n" + |
| 2914 | " public static void main(String[] args) {\n" + |
| 2915 | " Team4115irmrv1 t = new Team4115irmrv1();\n" + |
| 2916 | "\n" + |
| 2917 | " t.activate();\n" + |
| 2918 | "\n" + |
| 2919 | " T4115irmrv1 o = new T4115irmrv1();\n" + |
| 2920 | "\n" + |
| 2921 | " o.test();\n" + |
| 2922 | " System.out.print(T4115irmrv1.value);\n" + |
| 2923 | " }\n" + |
| 2924 | "}\n" + |
| 2925 | " \n", |
| 2926 | "T4115irmrv1.java", |
| 2927 | "\n" + |
| 2928 | "public class T4115irmrv1 {\n" + |
| 2929 | " public static int value = 1;\n" + |
| 2930 | " public void test() {\n" + |
| 2931 | " value += 10;\n" + |
| 2932 | " }\n" + |
| 2933 | "}\n" + |
| 2934 | " \n", |
| 2935 | "Team4115irmrv1.java", |
| 2936 | "\n" + |
| 2937 | "public team class Team4115irmrv1 {\n" + |
| 2938 | "\n" + |
| 2939 | " public class Role4115irmrv1 playedBy T4115irmrv1 {\n" + |
| 2940 | " public int test() {\n" + |
| 2941 | " return T4115irmrv1.value *= 2;\n" + |
| 2942 | " }\n" + |
| 2943 | " test <- before test;\n" + |
| 2944 | " }\n" + |
| 2945 | "}\n" + |
| 2946 | " \n" |
| 2947 | }, |
| 2948 | "12"); |
| 2949 | } |
| 2950 | |
| 2951 | // a role method with a return type is callin-bound as 'after' to a base method without a return type |
| 2952 | // 4.1.15-otjld-ignore-role-method-return-value-2 |
| 2953 | public void test4115_ignoreRoleMethodReturnValue2() { |
| 2954 | |
| 2955 | runConformTest( |
| 2956 | new String[] { |
| 2957 | "T4115irmrv2Main.java", |
| 2958 | "\n" + |
| 2959 | "public class T4115irmrv2Main {\n" + |
| 2960 | " public static void main(String[] args) {\n" + |
| 2961 | " Team4115irmrv2 t = new Team4115irmrv2();\n" + |
| 2962 | "\n" + |
| 2963 | " t.activate();\n" + |
| 2964 | "\n" + |
| 2965 | " T4115irmrv2 o = new T4115irmrv2();\n" + |
| 2966 | "\n" + |
| 2967 | " o.test();\n" + |
| 2968 | " System.out.print(T4115irmrv2.value);\n" + |
| 2969 | " }\n" + |
| 2970 | "}\n" + |
| 2971 | " \n", |
| 2972 | "T4115irmrv2.java", |
| 2973 | "\n" + |
| 2974 | "public class T4115irmrv2 {\n" + |
| 2975 | " public static int value = 1;\n" + |
| 2976 | " public void test() {\n" + |
| 2977 | " value += 10;\n" + |
| 2978 | " }\n" + |
| 2979 | "}\n" + |
| 2980 | " \n", |
| 2981 | "Team4115irmrv2.java", |
| 2982 | "\n" + |
| 2983 | "public team class Team4115irmrv2 {\n" + |
| 2984 | "\n" + |
| 2985 | " public class Role4115irmrv2 playedBy T4115irmrv2 {\n" + |
| 2986 | " public int getValue() {\n" + |
| 2987 | " return T4115irmrv2.value *= 2;\n" + |
| 2988 | " }\n" + |
| 2989 | " int getValue() <- after void test();\n" + |
| 2990 | " }\n" + |
| 2991 | "}\n" + |
| 2992 | " \n" |
| 2993 | }, |
| 2994 | "22"); |
| 2995 | } |
| 2996 | |
| 2997 | // a role method with a return type is callin-bound as 'after' to a base method with a matching return type |
| 2998 | // expect warning |
| 2999 | public void test4115_ignoreRoleMethodReturnValue3() { |
| 3000 | |
| 3001 | runTestExpectingWarnings( |
| 3002 | new String[] { |
| 3003 | "T4115irmrv3.java", |
| 3004 | "\n" + |
| 3005 | "public class T4115irmrv3 {\n" + |
| 3006 | " public static int value = 1;\n" + |
| 3007 | " public int test() {\n" + |
| 3008 | " value += 10;\n" + |
| 3009 | " return value;\n" + |
| 3010 | " }\n" + |
| 3011 | "}\n" + |
| 3012 | " \n", |
| 3013 | "Team4115irmrv3.java", |
| 3014 | "\n" + |
| 3015 | "public team class Team4115irmrv3 {\n" + |
| 3016 | "\n" + |
| 3017 | " public class Role4115irmrv3 playedBy T4115irmrv3 {\n" + |
| 3018 | " public int test() {\n" + |
| 3019 | " return T4115irmrv3.value *= 2;\n" + |
| 3020 | " }\n" + |
| 3021 | " test <- after test;\n" + |
| 3022 | " }\n" + |
| 3023 | "}\n" + |
| 3024 | " \n" |
| 3025 | }, |
| 3026 | "----------\n" + |
| 3027 | "1. WARNING in Team4115irmrv3.java (at line 8)\n" + |
| 3028 | " test <- after test;\n" + |
| 3029 | " ^^^^\n" + |
| 3030 | "Callin after binding cannot return a value to the base caller, role method return value of type int will be ignored (OTJLD 4.4(a)).\n" + |
| 3031 | "----------\n"); |
| 3032 | } |
| 3033 | |
| 3034 | // a role method with a return type is callin-bound as 'before' to a base method with a matching return type |
| 3035 | // expect no warning, method specs have signatures |
| 3036 | public void test4115_ignoreRoleMethodReturnValue3b() { |
| 3037 | Map customOptions = getCompilerOptions(); |
| 3038 | customOptions.put(CompilerOptions.OPTION_ReportIgnoringRoleMethodReturn, CompilerOptions.ERROR); |
| 3039 | |
| 3040 | runConformTest( |
| 3041 | new String[] { |
| 3042 | "T4115irmrv3bMain.java", |
| 3043 | "\n" + |
| 3044 | "public class T4115irmrv3bMain {\n" + |
| 3045 | " public static void main(String[] args) {\n" + |
| 3046 | " Team4115irmrv3b t = new Team4115irmrv3b();\n" + |
| 3047 | "\n" + |
| 3048 | " t.activate();\n" + |
| 3049 | "\n" + |
| 3050 | " T4115irmrv3b o = new T4115irmrv3b();\n" + |
| 3051 | "\n" + |
| 3052 | " System.out.print(o.test());\n" + |
| 3053 | " System.out.print(T4115irmrv3b.value);\n" + |
| 3054 | " }\n" + |
| 3055 | "}\n" + |
| 3056 | " \n", |
| 3057 | "T4115irmrv3b.java", |
| 3058 | "\n" + |
| 3059 | "public class T4115irmrv3b {\n" + |
| 3060 | " public static int value = 1;\n" + |
| 3061 | " public int test() {\n" + |
| 3062 | " value += 10;\n" + |
| 3063 | " return value;\n" + |
| 3064 | " }\n" + |
| 3065 | "}\n" + |
| 3066 | " \n", |
| 3067 | "Team4115irmrv3b.java", |
| 3068 | "\n" + |
| 3069 | "public team class Team4115irmrv3b {\n" + |
| 3070 | "\n" + |
| 3071 | " public class Role4115irmrv3b playedBy T4115irmrv3b {\n" + |
| 3072 | " public int test() {\n" + |
| 3073 | " return T4115irmrv3b.value *= 2;\n" + |
| 3074 | " }\n" + |
| 3075 | " int test() <- before int test();\n" + |
| 3076 | " }\n" + |
| 3077 | "}\n" + |
| 3078 | " \n" |
| 3079 | }, |
| 3080 | "1212", |
| 3081 | null/*classLibraries*/, |
| 3082 | true/*shouldFlushOutputDirectory*/, |
| 3083 | null/*vmArguments*/, |
| 3084 | customOptions, |
| 3085 | null/*no custom requestor*/); |
| 3086 | } |
| 3087 | |
| 3088 | // a role method with a return type is callin-bound as 'after' to a base method with a matching return type |
| 3089 | // expect warning, method specs have signatures |
| 3090 | public void test4115_ignoreRoleMethodReturnValue3s() { |
| 3091 | Map customOptions = getCompilerOptions(); |
| 3092 | customOptions.put(CompilerOptions.OPTION_ReportIgnoringRoleMethodReturn, CompilerOptions.ERROR); |
| 3093 | |
| 3094 | runNegativeTest( |
| 3095 | new String[] { |
| 3096 | "T4115irmrv3s.java", |
| 3097 | "\n" + |
| 3098 | "public class T4115irmrv3s {\n" + |
| 3099 | " public static int value = 1;\n" + |
| 3100 | " public int test() {\n" + |
| 3101 | " value += 10;\n" + |
| 3102 | " return value;\n" + |
| 3103 | " }\n" + |
| 3104 | "}\n" + |
| 3105 | " \n", |
| 3106 | "Team4115irmrv3s.java", |
| 3107 | "\n" + |
| 3108 | "public team class Team4115irmrv3s {\n" + |
| 3109 | "\n" + |
| 3110 | " public class Role4115irmrv3s playedBy T4115irmrv3s {\n" + |
| 3111 | " public int test() {\n" + |
| 3112 | " return T4115irmrv3s.value *= 2;\n" + |
| 3113 | " }\n" + |
| 3114 | " int test() <- after int test();\n" + |
| 3115 | " }\n" + |
| 3116 | "}\n" + |
| 3117 | " \n" |
| 3118 | }, |
| 3119 | "----------\n" + |
| 3120 | "1. ERROR in Team4115irmrv3s.java (at line 8)\n" + |
| 3121 | " int test() <- after int test();\n" + |
| 3122 | " ^^^\n" + |
| 3123 | "Callin after binding cannot return a value to the base caller, role method return value of type int will be ignored (OTJLD 4.4(a)).\n" + |
| 3124 | "----------\n", |
| 3125 | null/*classLibraries*/, |
| 3126 | true/*shouldFlushOutputDirectory*/, |
| 3127 | customOptions); |
| 3128 | } |
| 3129 | |
| 3130 | // a role method with a return type is callin-bound as 'after' to a base method without a return type |
| 3131 | // warning suppressed |
| 3132 | public void test4115_ignoreRoleMethodReturnValue4() { |
| 3133 | |
| 3134 | runConformTest( |
| 3135 | new String[] { |
| 3136 | "T4115irmrv4Main.java", |
| 3137 | "\n" + |
| 3138 | "public class T4115irmrv4Main {\n" + |
| 3139 | " public static void main(String[] args) {\n" + |
| 3140 | " Team4115irmrv4 t = new Team4115irmrv4();\n" + |
| 3141 | "\n" + |
| 3142 | " t.activate();\n" + |
| 3143 | "\n" + |
| 3144 | " T4115irmrv4 o = new T4115irmrv4();\n" + |
| 3145 | "\n" + |
| 3146 | " System.out.print(o.test());\n" + |
| 3147 | " System.out.print(T4115irmrv4.value);\n" + |
| 3148 | " }\n" + |
| 3149 | "}\n" + |
| 3150 | " \n", |
| 3151 | "T4115irmrv4.java", |
| 3152 | "\n" + |
| 3153 | "public class T4115irmrv4 {\n" + |
| 3154 | " public static int value = 1;\n" + |
| 3155 | " public int test() {\n" + |
| 3156 | " value += 10;\n" + |
| 3157 | " return value;\n" + |
| 3158 | " }\n" + |
| 3159 | "}\n" + |
| 3160 | " \n", |
| 3161 | "Team4115irmrv4.java", |
| 3162 | "\n" + |
| 3163 | "public team class Team4115irmrv4 {\n" + |
| 3164 | "\n" + |
| 3165 | " public class Role4115irmrv4 playedBy T4115irmrv4 {\n" + |
| 3166 | " public int getValue() {\n" + |
| 3167 | " return T4115irmrv4.value *= 2;\n" + |
| 3168 | " }\n" + |
| 3169 | " @SuppressWarnings(\"ignoredresult\")\n" + |
| 3170 | " int getValue() <- after int test();\n" + |
| 3171 | " }\n" + |
| 3172 | "}\n" + |
| 3173 | " \n" |
| 3174 | }, |
| 3175 | "1122"); |
| 3176 | } |
| 3177 | |
| 3178 | // a role method is callin-bound as 'replace' to a base method that has a non-conforming return type |
| 3179 | // 4.1.16-otjld-non-conforming-return-types-1 |
| 3180 | public void test4116_nonConformingReturnTypes1() { |
| 3181 | runNegativeTest( |
| 3182 | new String[] { |
| 3183 | "T4116ncrt1.java", |
| 3184 | "\n" + |
| 3185 | "public class T4116ncrt1 {\n" + |
| 3186 | " public int test() {\n" + |
| 3187 | " return 0;\n" + |
| 3188 | " }\n" + |
| 3189 | "}\n" + |
| 3190 | " \n", |
| 3191 | "Team4116ncrt1.java", |
| 3192 | "\n" + |
| 3193 | "public team class Team4116ncrt1 {\n" + |
| 3194 | "\n" + |
| 3195 | " public class Role4116ncrt1 playedBy T4116ncrt1 {\n" + |
| 3196 | " callin short test() {\n" + |
| 3197 | " // it would work if not for the base call\n" + |
| 3198 | " return base.test();\n" + |
| 3199 | " }\n" + |
| 3200 | " short test() <- replace int test();\n" + |
| 3201 | " }\n" + |
| 3202 | "}\n" + |
| 3203 | " \n" |
| 3204 | }, |
| 3205 | null); |
| 3206 | } |
| 3207 | |
| 3208 | // a role method is callin-bound as 'replace' to a base method that has a non-conforming return type |
| 3209 | // 4.1.16-otjld-non-conforming-return-types-2 |
| 3210 | public void test4116_nonConformingReturnTypes2() { |
| 3211 | runNegativeTest( |
| 3212 | new String[] { |
| 3213 | "T4116ncrt2.java", |
| 3214 | "\n" + |
| 3215 | "public class T4116ncrt2 {\n" + |
| 3216 | " public short test() {\n" + |
| 3217 | " return 0;\n" + |
| 3218 | " }\n" + |
| 3219 | "}\n" + |
| 3220 | " \n", |
| 3221 | "Team4116ncrt2.java", |
| 3222 | "\n" + |
| 3223 | "public team class Team4116ncrt2 {\n" + |
| 3224 | "\n" + |
| 3225 | " public class Role4116ncrt2 playedBy T4116ncrt2 {\n" + |
| 3226 | " callin int test() {\n" + |
| 3227 | " return base.test();\n" + |
| 3228 | " }\n" + |
| 3229 | " int test() <- replace short test();\n" + |
| 3230 | " }\n" + |
| 3231 | "}\n" + |
| 3232 | " \n" |
| 3233 | }, |
| 3234 | null); |
| 3235 | } |
| 3236 | |
| 3237 | // a role method is callin-bound as 'replace' to a base method that has a non-conforming return type |
| 3238 | // 4.1.16-otjld-non-conforming-return-types-3 |
| 3239 | public void test4116_nonConformingReturnTypes3() { |
| 3240 | runNegativeTestMatching( |
| 3241 | new String[] { |
| 3242 | "Team4116ncrt3.java", |
| 3243 | "\n" + |
| 3244 | "public team class Team4116ncrt3 {\n" + |
| 3245 | "\n" + |
| 3246 | " public class Role4116ncrt3 playedBy T4116ncrt3 {\n" + |
| 3247 | " // warning because we do not call the base method\n" + |
| 3248 | " callin String test(String arg) {\n" + |
| 3249 | " return arg;\n" + |
| 3250 | " }\n" + |
| 3251 | " test <- replace test;\n" + |
| 3252 | " }\n" + |
| 3253 | "}\n" + |
| 3254 | " \n", |
| 3255 | "T4116ncrt3.java", |
| 3256 | "\n" + |
| 3257 | "public class T4116ncrt3 {\n" + |
| 3258 | " public Object[] test(String arg) {\n" + |
| 3259 | " return null;\n" + |
| 3260 | " }\n" + |
| 3261 | "}\n" + |
| 3262 | " \n" |
| 3263 | }, |
| 3264 | "4.4(b)"); |
| 3265 | } |
| 3266 | |
| 3267 | // a role method with a callin modifier is callin-bound as 'before' |
| 3268 | // 4.1.17-otjld-illegal-use-of-callin-modifier-1 |
| 3269 | public void test4117_illegalUseOfCallinModifier1() { |
| 3270 | runNegativeTest( |
| 3271 | new String[] { |
| 3272 | "T4117iuocm1.java", |
| 3273 | "\n" + |
| 3274 | "public class T4117iuocm1 {\n" + |
| 3275 | " public void test() {}\n" + |
| 3276 | "}\n" + |
| 3277 | " \n", |
| 3278 | "Team4117iuocm1.java", |
| 3279 | "\n" + |
| 3280 | "public team class Team4117iuocm1 {\n" + |
| 3281 | "\n" + |
| 3282 | " public class Role4117iuocm1 playedBy T4117iuocm1 {\n" + |
| 3283 | " callin void test() {\n" + |
| 3284 | " base.test();\n" + |
| 3285 | " }\n" + |
| 3286 | " test <- before test;\n" + |
| 3287 | " }\n" + |
| 3288 | "}\n" + |
| 3289 | " \n" |
| 3290 | }, |
| 3291 | null); |
| 3292 | } |
| 3293 | |
| 3294 | // a role method with a callin modifier is callin-bound as 'after' |
| 3295 | // 4.1.17-otjld-illegal-use-of-callin-modifier-2 |
| 3296 | public void test4117_illegalUseOfCallinModifier2() { |
| 3297 | runNegativeTest( |
| 3298 | new String[] { |
| 3299 | "Team4117iuocm2.java", |
| 3300 | "\n" + |
| 3301 | "public team class Team4117iuocm2 {\n" + |
| 3302 | "\n" + |
| 3303 | " public class Role4117iuocm2 playedBy T4117iuocm2 {\n" + |
| 3304 | " callin void test1() {\n" + |
| 3305 | " base.test1();\n" + |
| 3306 | " }\n" + |
| 3307 | " void test1() <- after void test();\n" + |
| 3308 | " }\n" + |
| 3309 | "}\n" + |
| 3310 | " \n", |
| 3311 | "T4117iuocm2.java", |
| 3312 | "\n" + |
| 3313 | "public class T4117iuocm2 {\n" + |
| 3314 | " public void test() {}\n" + |
| 3315 | "}\n" + |
| 3316 | " \n" |
| 3317 | }, |
| 3318 | "----------\n" + |
| 3319 | "1. ERROR in Team4117iuocm2.java (at line 8)\n" + |
| 3320 | " void test1() <- after void test();\n" + |
| 3321 | " ^^^^^^^^^^^^\n" + |
| 3322 | "Cannot bind callin method test1() using \"after\" (OTJLD 4.2(d)).\n" + |
| 3323 | "----------\n"); |
| 3324 | } |
| 3325 | |
| 3326 | // a role method without a callin modifier is callin-bound as 'replace' |
| 3327 | // 4.1.18-otjld-missing-callin-modifier-1 |
| 3328 | public void test4118_missingCallinModifier1() { |
| 3329 | runNegativeTest( |
| 3330 | new String[] { |
| 3331 | "T4118mcm1.java", |
| 3332 | "\n" + |
| 3333 | "public class T4118mcm1 {\n" + |
| 3334 | " public void test() {}\n" + |
| 3335 | "}\n" + |
| 3336 | " \n", |
| 3337 | "Team4118mcm1.java", |
| 3338 | "\n" + |
| 3339 | "public team class Team4118mcm1 {\n" + |
| 3340 | "\n" + |
| 3341 | " public class Role4118mcm1 playedBy T4118mcm1 {\n" + |
| 3342 | " public void test() {}\n" + |
| 3343 | " test <- replace test;\n" + |
| 3344 | " }\n" + |
| 3345 | "}\n" + |
| 3346 | " \n" |
| 3347 | }, |
| 3348 | null); |
| 3349 | } |
| 3350 | |
| 3351 | // a role method without a callin modifier is callin-bound as 'replace' |
| 3352 | // 4.1.18-otjld-missing-callin-modifier-2 |
| 3353 | public void test4118_missingCallinModifier2() { |
| 3354 | runNegativeTest( |
| 3355 | new String[] { |
| 3356 | "T4118mcm2.java", |
| 3357 | "\n" + |
| 3358 | "public class T4118mcm2 {\n" + |
| 3359 | " public void test() {}\n" + |
| 3360 | "}\n" + |
| 3361 | " \n", |
| 3362 | "Team4118mcm2.java", |
| 3363 | "\n" + |
| 3364 | "public team class Team4118mcm2 {\n" + |
| 3365 | "\n" + |
| 3366 | " public class Role4118mcm2 playedBy T4118mcm2 {\n" + |
| 3367 | " public void test() {}\n" + |
| 3368 | " void test() <- replace void test();\n" + |
| 3369 | " }\n" + |
| 3370 | "}\n" + |
| 3371 | " \n" |
| 3372 | }, |
| 3373 | null); |
| 3374 | } |
| 3375 | |
| 3376 | // a replace-callin binding has no replace binding |
| 3377 | // 4.1.20-otjld-missing-replace-modifier |
| 3378 | public void test4120_missingReplaceModifier() { |
| 3379 | runNegativeTest( |
| 3380 | new String[] { |
| 3381 | "T4120mrm.java", |
| 3382 | "\n" + |
| 3383 | "public class T4120mrm {\n" + |
| 3384 | " public void test() {}\n" + |
| 3385 | "}\n" + |
| 3386 | " \n", |
| 3387 | "Team4120mrm.java", |
| 3388 | "\n" + |
| 3389 | "public team class Team4120mrm {\n" + |
| 3390 | "\n" + |
| 3391 | " public class Role4120mrm playedBy T4120mrm {\n" + |
| 3392 | " callin void test() { base.test(); }\n" + |
| 3393 | " void test() <- void test();\n" + |
| 3394 | " }\n" + |
| 3395 | "}\n" + |
| 3396 | " \n" |
| 3397 | }, |
| 3398 | null); |
| 3399 | } |
| 3400 | |
| 3401 | // a callin binding to multiple methods, each with a binding modifier |
| 3402 | // 4.1.21-otjld-multiple-bound-methods-with-modifiers-1 |
| 3403 | public void test4121_multipleBoundMethodsWithModifiers1() { |
| 3404 | runNegativeTest( |
| 3405 | new String[] { |
| 3406 | "T4121mbmwm1.java", |
| 3407 | "\n" + |
| 3408 | "public class T4121mbmwm1 {\n" + |
| 3409 | " public void test1() {}\n" + |
| 3410 | " public void test2() {}\n" + |
| 3411 | "}\n" + |
| 3412 | " \n", |
| 3413 | "Team4121mbmwm1.java", |
| 3414 | "\n" + |
| 3415 | "public team class Team4121mbmwm1 {\n" + |
| 3416 | "\n" + |
| 3417 | " public class Role4121mbmwm1 playedBy T4121mbmwm1 {\n" + |
| 3418 | " public void test() {}\n" + |
| 3419 | " test <- before test1, after test2;\n" + |
| 3420 | " }\n" + |
| 3421 | "}\n" + |
| 3422 | " \n" |
| 3423 | }, |
| 3424 | null); |
| 3425 | } |
| 3426 | |
| 3427 | // a callin binding to multiple methods, each with a binding modifier |
| 3428 | // 4.1.21-otjld-multiple-bound-methods-with-modifiers-2 |
| 3429 | public void test4121_multipleBoundMethodsWithModifiers2() { |
| 3430 | runNegativeTest( |
| 3431 | new String[] { |
| 3432 | "T4121mbmwm2.java", |
| 3433 | "\n" + |
| 3434 | "public class T4121mbmwm2 {\n" + |
| 3435 | " public void test1() {}\n" + |
| 3436 | " public void test2() {}\n" + |
| 3437 | "}\n" + |
| 3438 | " \n", |
| 3439 | "Team4121mbmwm2.java", |
| 3440 | "\n" + |
| 3441 | "public team class Team4121mbmwm2 {\n" + |
| 3442 | "\n" + |
| 3443 | " public class Role4121mbmwm2 playedBy T4121mbmwm2 {\n" + |
| 3444 | " callin void test() {}\n" + |
| 3445 | " test <- before test1, replace test2;\n" + |
| 3446 | " }\n" + |
| 3447 | "}\n" + |
| 3448 | " \n" |
| 3449 | }, |
| 3450 | null); |
| 3451 | } |
| 3452 | |
| 3453 | // a callin binding binds an implicitly inherted method which has a role parameter |
| 3454 | // 4.1.22-otjld-binding-tsuper-method-with-signature |
| 3455 | public void test4122_bindingTsuperMethodWithSignature() { |
| 3456 | |
| 3457 | runConformTest( |
| 3458 | new String[] { |
| 3459 | "Team4122btmws_2.java", |
| 3460 | "\n" + |
| 3461 | "public team class Team4122btmws_2 extends Team4122btmws_1 {\n" + |
| 3462 | " protected class R1 {\n" + |
| 3463 | " void bar(R2 r) <- after void foo(T4122btmws b);\n" + |
| 3464 | " }\n" + |
| 3465 | " protected class R2 {\n" + |
| 3466 | " protected void test() {\n" + |
| 3467 | " System.out.print(\"K\");\n" + |
| 3468 | " }\n" + |
| 3469 | " }\n" + |
| 3470 | " Team4122btmws_2 () {\n" + |
| 3471 | " activate();\n" + |
| 3472 | " T4122btmws b1 = new T4122btmws(\"foo\");\n" + |
| 3473 | " b1.foo(new T4122btmws(\"O\"));\n" + |
| 3474 | " }\n" + |
| 3475 | " public static void main (String[] args) {\n" + |
| 3476 | " new Team4122btmws_2();\n" + |
| 3477 | " }\n" + |
| 3478 | "}\n" + |
| 3479 | " \n", |
| 3480 | "T4122btmws.java", |
| 3481 | "\n" + |
| 3482 | "public class T4122btmws {\n" + |
| 3483 | " private String val;\n" + |
| 3484 | " T4122btmws(String v) {\n" + |
| 3485 | " val = v;\n" + |
| 3486 | " }\n" + |
| 3487 | " void foo(T4122btmws other) {\n" + |
| 3488 | " other.test();\n" + |
| 3489 | " }\n" + |
| 3490 | " private void test() { \n" + |
| 3491 | " System.out.print(val); \n" + |
| 3492 | " }\n" + |
| 3493 | "}\n" + |
| 3494 | " \n", |
| 3495 | "Team4122btmws_1.java", |
| 3496 | "\n" + |
| 3497 | "public team class Team4122btmws_1 {\n" + |
| 3498 | " protected class R1 playedBy T4122btmws {\n" + |
| 3499 | " void bar(R2 r) {\n" + |
| 3500 | " r.test();\n" + |
| 3501 | " }\n" + |
| 3502 | " }\n" + |
| 3503 | " protected class R2 playedBy T4122btmws {\n" + |
| 3504 | " protected void test() {\n" + |
| 3505 | " System.out.print(\"NOK\");\n" + |
| 3506 | " }\n" + |
| 3507 | " }\n" + |
| 3508 | "}\n" + |
| 3509 | " \n" |
| 3510 | }, |
| 3511 | "OK"); |
| 3512 | } |
| 3513 | |
| 3514 | // a callin method is bound to an inaccessible base method and has a base call |
| 3515 | // 4.1.23-otjld-callin-with-basecall-to-inaccessible-1 |
| 3516 | public void test4123_callinWithBasecallToInaccessible1() { |
| 3517 | Map customOptions = getCompilerOptions(); |
| 3518 | customOptions.put(CompilerOptions.OPTION_Decapsulation, CompilerOptions.REPORT_NONE); |
| 3519 | runConformTest( |
| 3520 | new String[] { |
| 3521 | "Team4123cwbti1.java", |
| 3522 | "\n" + |
| 3523 | "public team class Team4123cwbti1 {\n" + |
| 3524 | " protected class R playedBy T4123cwbti1 {\n" + |
| 3525 | " callin void test() {\n" + |
| 3526 | " base.test();\n" + |
| 3527 | " System.out.print(\"K\");\n" + |
| 3528 | " }\n" + |
| 3529 | " void test() <- replace void test();\n" + |
| 3530 | " }\n" + |
| 3531 | " public static void main(String[] args) {\n" + |
| 3532 | " Team4123cwbti1 t = new Team4123cwbti1();\n" + |
| 3533 | " t.activate();\n" + |
| 3534 | " T4123cwbti1 b = new T4123cwbti1();\n" + |
| 3535 | " b.go();\n" + |
| 3536 | " }\n" + |
| 3537 | "} \n" + |
| 3538 | " \n", |
| 3539 | "T4123cwbti1.java", |
| 3540 | "\n" + |
| 3541 | "public class T4123cwbti1 {\n" + |
| 3542 | " private void test() {\n" + |
| 3543 | " System.out.print(\"O\");\n" + |
| 3544 | " }\n" + |
| 3545 | " public void go() {\n" + |
| 3546 | " test();\n" + |
| 3547 | " }\n" + |
| 3548 | "}\n" + |
| 3549 | " \n" |
| 3550 | }, |
| 3551 | "OK", |
| 3552 | null/*classLibraries*/, |
| 3553 | true/*shouldFlushOutputDirectory*/, |
| 3554 | null/*vmArguments*/, |
| 3555 | customOptions, |
| 3556 | null/*no custom requestor*/); |
| 3557 | } |
| 3558 | |
| 3559 | // a callin method is directly called |
| 3560 | // 4.1.24-otjld-directly-call-callin-method-1 |
| 3561 | public void test4124_directlyCallCallinMethod1() { |
| 3562 | runNegativeTestMatching( |
| 3563 | new String[] { |
| 3564 | "Team4124dccm1.java", |
| 3565 | " \n" + |
| 3566 | "public team class Team4124dccm1 {\n" + |
| 3567 | " public class RoleA { \n" + |
| 3568 | " int x = someMethod(); \n" + |
| 3569 | " \n" + |
| 3570 | " callin int someMethod() { \n" + |
| 3571 | " return 1979; \n" + |
| 3572 | " } \n" + |
| 3573 | " } \n" + |
| 3574 | "} \n" + |
| 3575 | " \n" |
| 3576 | }, |
| 3577 | "4.2(d)"); |
| 3578 | } |
| 3579 | |
| 3580 | // a after callin binding maps "result" to an argument |
| 3581 | // 4.1.25-otjld-result-in-after-binding-1 |
| 3582 | public void test4125_resultInAfterBinding1() { |
| 3583 | |
| 3584 | runConformTest( |
| 3585 | new String[] { |
| 3586 | "Team4125riab1.java", |
| 3587 | "\n" + |
| 3588 | "public team class Team4125riab1 {\n" + |
| 3589 | " public class R playedBy T4125riab1 {\n" + |
| 3590 | " void log(String v) {\n" + |
| 3591 | " System.out.print(v);\n" + |
| 3592 | " }\n" + |
| 3593 | " void log(String v) <- after String getVal() with {\n" + |
| 3594 | " v <- result\n" + |
| 3595 | " }\n" + |
| 3596 | " }\n" + |
| 3597 | " public static void main(String[] args) {\n" + |
| 3598 | " (new Team4125riab1()).activate();\n" + |
| 3599 | " (new T4125riab1()).getVal();\n" + |
| 3600 | " }\n" + |
| 3601 | "}\n" + |
| 3602 | " \n", |
| 3603 | "T4125riab1.java", |
| 3604 | "\n" + |
| 3605 | "public class T4125riab1 { \n" + |
| 3606 | " String getVal() { return \"OK\"; }\n" + |
| 3607 | "} \n" + |
| 3608 | " \n" |
| 3609 | }, |
| 3610 | "OK"); |
| 3611 | } |
| 3612 | |
| 3613 | // a before callin binding maps "result" to an argument |
| 3614 | // 4.1.25-otjld-result-in-before-binding-2 |
| 3615 | public void test4125_resultInBeforeBinding2() { |
| 3616 | runNegativeTest( |
| 3617 | new String[] { |
| 3618 | "T4125ribb2.java", |
| 3619 | "\n" + |
| 3620 | "public class T4125ribb2 { \n" + |
| 3621 | " String getVal() { return \"OK\"; }\n" + |
| 3622 | "} \n" + |
| 3623 | " \n", |
| 3624 | "Team4125ribb2.java", |
| 3625 | "\n" + |
| 3626 | "public team class Team4125ribb2 {\n" + |
| 3627 | " public class R playedBy T4125ribb2 {\n" + |
| 3628 | " void log(String v) {\n" + |
| 3629 | " System.out.print(v);\n" + |
| 3630 | " }\n" + |
| 3631 | " void log(String v) <- before String getVal() with {\n" + |
| 3632 | " v <- result\n" + |
| 3633 | " }\n" + |
| 3634 | " }\n" + |
| 3635 | " public static void main(String[] args) {\n" + |
| 3636 | " (new Team4125ribb2()).activate();\n" + |
| 3637 | " (new T4125ribb2()).getVal();\n" + |
| 3638 | " }\n" + |
| 3639 | "}\n" + |
| 3640 | " \n" |
| 3641 | }, |
| 3642 | null); |
| 3643 | } |
| 3644 | |
| 3645 | // the name "result" is used in a method spec of a parameter-mapping-les callin (could work) |
| 3646 | public void test4125_resultInMethodSpec3() { |
| 3647 | runConformTest( |
| 3648 | new String[] { |
| 3649 | "Team4125rims3.java", |
| 3650 | "import java.util.ArrayList;\n" + |
| 3651 | "import java.util.List;\n" + |
| 3652 | "\n" + |
| 3653 | "public team class Team4125rims3 {\n" + |
| 3654 | "\n" + |
| 3655 | " protected class R playedBy T4125rims3 {\n" + |
| 3656 | " <T> void safeAppend(T el, List<T> result) <- replace void append(T el, List<T> result);\n" + |
| 3657 | " callin <T> void safeAppend(T el, List<T> result) {\n" + |
| 3658 | " if (el != null)\n" + |
| 3659 | " base.safeAppend(el, result);\n" + |
| 3660 | " }\n" + |
| 3661 | " }\n" + |
| 3662 | " public static void main(String[] args) {\n" + |
| 3663 | " new Team4125rims3().activate();\n" + |
| 3664 | " List<String> strings = new ArrayList<String>();\n" + |
| 3665 | " strings.add(\"O\");\n" + |
| 3666 | " T4125rims3 appender = new T4125rims3();\n" + |
| 3667 | " appender.append(null, strings);\n" + |
| 3668 | " appender.append(\"K\", strings);\n" + |
| 3669 | " for (String string : strings) {\n" + |
| 3670 | " System.out.print(string);\n" + |
| 3671 | " }\n" + |
| 3672 | " }\n" + |
| 3673 | "}\n", |
| 3674 | "T4125rims3.java", |
| 3675 | "import java.util.List;\n" + |
| 3676 | "\n" + |
| 3677 | "\n" + |
| 3678 | "public class T4125rims3 {\n" + |
| 3679 | " <T> void append(T el, List<T> result) {\n" + |
| 3680 | " result.add(el);\n" + |
| 3681 | " }\n" + |
| 3682 | "}\n", |
| 3683 | }, |
| 3684 | "OK"); |
| 3685 | } |
| 3686 | |
| 3687 | // a callin binding has a label |
| 3688 | // 4.1.26-otjld-name-callin-binding-1 |
| 3689 | public void test4126_nameCallinBinding1() { |
| 3690 | runConformTest( |
| 3691 | new String[] { |
| 3692 | "Team4126ncb1.java", |
| 3693 | "\n" + |
| 3694 | "import base p.Team4126ncb1_0;\n" + |
| 3695 | "public team class Team4126ncb1 {\n" + |
| 3696 | " public class R playedBy Team4126ncb1_0 {\n" + |
| 3697 | " void rm() {};\n" + |
| 3698 | " \n" + |
| 3699 | " logActivate:\n" + |
| 3700 | " void rm() <- after void activate();\n" + |
| 3701 | " }\n" + |
| 3702 | "}\n", |
| 3703 | "p/Team4126ncb1_0.java", |
| 3704 | "package p;\n" + |
| 3705 | "public team class Team4126ncb1_0 { }\n" |
| 3706 | }); |
| 3707 | } |
| 3708 | |
| 3709 | // a callin binding has a label with syntax error |
| 3710 | // 4.1.26-otjld-name-callin-binding-2 |
| 3711 | public void test4126_nameCallinBinding2() { |
| 3712 | runNegativeTestMatching( |
| 3713 | new String[] { |
| 3714 | "Team4126ncb2.java", |
| 3715 | "\n" + |
| 3716 | "import base p1.Team4126ncb2_0;\n" + |
| 3717 | "public team class Team4126ncb2 {\n" + |
| 3718 | " public class R playedBy Team4126ncb2_0 {\n" + |
| 3719 | " void rm() {};\n" + |
| 3720 | " \n" + |
| 3721 | " public logActivate:\n" + |
| 3722 | " void rm() <- after void activate();\n" + |
| 3723 | " }\n" + |
| 3724 | "}\n", |
| 3725 | "p/Team4126ncb2_0.java", |
| 3726 | "package p;\n" + |
| 3727 | "public team class Team4126ncb2_0 { }\n" |
| 3728 | }, |
| 3729 | "Syntax error"); |
| 3730 | } |
| 3731 | |
| 3732 | // a callin binding has a label with syntax error |
| 3733 | // 4.1.26-otjld-name-callin-binding-3 |
| 3734 | public void test4126_nameCallinBinding3() { |
| 3735 | runNegativeTestMatching( |
| 3736 | new String[] { |
| 3737 | "Team4126ncb3.java", |
| 3738 | "\n" + |
| 3739 | "import base p1.Team4126ncb3_0;\n" + |
| 3740 | "public team class Team4126ncb3 {\n" + |
| 3741 | " public class R playedBy Team4126ncb3_0 {\n" + |
| 3742 | " void rm() {};\n" + |
| 3743 | " \n" + |
| 3744 | " logActivate[]:\n" + |
| 3745 | " void rm() <- after void activate();\n" + |
| 3746 | " }\n" + |
| 3747 | "}\n", |
| 3748 | "p/Team4126ncb3_0.java", |
| 3749 | "package p;\n" + |
| 3750 | "public team class Team4126ncb3_0 { }\n" |
| 3751 | }, |
| 3752 | "Syntax error"); |
| 3753 | } |
| 3754 | |
| 3755 | // a callin binding has a label with syntax error |
| 3756 | // 4.1.26-otjld-name-callin-binding-4 |
| 3757 | public void test4126_nameCallinBinding4() { |
| 3758 | runNegativeTestMatching( |
| 3759 | new String[] { |
| 3760 | "Team4126ncb4.java", |
| 3761 | "\n" + |
| 3762 | "import base p.Team4126ncb4_0;\n" + |
| 3763 | "public team class Team4126ncb4 {\n" + |
| 3764 | " public class R playedBy Team4126ncb4_0 {\n" + |
| 3765 | " void rm() {};\n" + |
| 3766 | " \n" + |
| 3767 | " private synchronized logActivate[]:\n" + |
| 3768 | " void rm() <- after void activate();\n" + |
| 3769 | " }\n" + |
| 3770 | "}\n", |
| 3771 | "p/Team4126ncb4_0.java", |
| 3772 | "package p;\n" + |
| 3773 | "public team class Team4126ncb4_0 { }\n" |
| 3774 | }, |
| 3775 | "Syntax error"); |
| 3776 | } |
| 3777 | |
| 3778 | // a callin binding has a label with syntax error |
| 3779 | // 4.1.26-otjld-name-callin-binding-5 |
| 3780 | public void test4126_nameCallinBinding5() { |
| 3781 | runNegativeTestMatching( |
| 3782 | new String[] { |
| 3783 | "Team4126ncb5.java", |
| 3784 | "\n" + |
| 3785 | "import base p.Team4126ncb5_0;\n" + |
| 3786 | "public team class Team4126ncb5 {\n" + |
| 3787 | " public class R playedBy Team4126ncb5_0 {\n" + |
| 3788 | " void rm() {};\n" + |
| 3789 | " \n" + |
| 3790 | " logActivate as bar:\n" + |
| 3791 | " void rm() <- after void activate();\n" + |
| 3792 | " }\n" + |
| 3793 | "}\n", |
| 3794 | "p/Team4126ncb5_0.java", |
| 3795 | "package p;\n" + |
| 3796 | "public team class Team4126ncb5_0 { }\n" |
| 3797 | }, |
| 3798 | "Syntax error"); |
| 3799 | } |
| 3800 | |
| 3801 | // a long callin binding has a label |
| 3802 | // 4.1.26-otjld-name-callin-binding-6 |
| 3803 | public void test4126_nameCallinBinding6() { |
| 3804 | runConformTest( |
| 3805 | new String[] { |
| 3806 | "Team4126ncb6.java", |
| 3807 | "\n" + |
| 3808 | "public team class Team4126ncb6 {\n" + |
| 3809 | " @SuppressWarnings(\"bindingconventions\") // fqn base class\n" + |
| 3810 | " public class R playedBy p.Team4126ncb6_0 {\n" + |
| 3811 | " void rm() {};\n" + |
| 3812 | " \n" + |
| 3813 | " logActivate:\n" + |
| 3814 | " void rm() <- after void activate();\n" + |
| 3815 | " }\n" + |
| 3816 | "} \n" + |
| 3817 | " \n", |
| 3818 | "p/Team4126ncb6_0.java", |
| 3819 | "package p;\n" + |
| 3820 | "public team class Team4126ncb6_0 { }\n" |
| 3821 | }); |
| 3822 | } |
| 3823 | |
| 3824 | // a team has a precedence declaration |
| 3825 | // 4.1.27-otjld-precedence-declaration-1 |
| 3826 | public void test4127_precedenceDeclaration1() { |
| 3827 | |
| 3828 | runConformTest( |
| 3829 | new String[] { |
| 3830 | "Team4127pd1.java", |
| 3831 | "\n" + |
| 3832 | "public team class Team4127pd1 {\n" + |
| 3833 | " public class R playedBy T4127pd1 {\n" + |
| 3834 | " void rm1() {\n" + |
| 3835 | " System.out.print(\"K\");\n" + |
| 3836 | " }\n" + |
| 3837 | " void rm2() { \n" + |
| 3838 | " System.out.print(\"O\"); \n" + |
| 3839 | " }\n" + |
| 3840 | " b1: rm1 <- after bm;\n" + |
| 3841 | " b2: rm2 <- after bm;\n" + |
| 3842 | " }\n" + |
| 3843 | " precedence after R.b1, R.b2;\n" + |
| 3844 | " public static void main(String[] args) {\n" + |
| 3845 | " Team4127pd1 t = new Team4127pd1();\n" + |
| 3846 | " t.activate();\n" + |
| 3847 | " T4127pd1 b = new T4127pd1();\n" + |
| 3848 | " b.bm();\n" + |
| 3849 | " }\n" + |
| 3850 | "} \n" + |
| 3851 | " \n", |
| 3852 | "T4127pd1.java", |
| 3853 | "\n" + |
| 3854 | "public class T4127pd1 {\n" + |
| 3855 | " void bm() { }\n" + |
| 3856 | "} \n" + |
| 3857 | " \n" |
| 3858 | }, |
| 3859 | "OK"); |
| 3860 | } |
| 3861 | // a team has a class-level precedence declaration |
| 3862 | public void test4127_precedenceDeclaration1c() { |
| 3863 | |
| 3864 | runConformTest( |
| 3865 | new String[] { |
| 3866 | "Team4127pd1c.java", |
| 3867 | "\n" + |
| 3868 | "public team class Team4127pd1c {\n" + |
| 3869 | " public class R1 playedBy T4127pd1c {\n" + |
| 3870 | " void rm1() {\n" + |
| 3871 | " System.out.print(\"K\");\n" + |
| 3872 | " }\n" + |
| 3873 | " rm1 <- after bm;\n" + |
| 3874 | " }\n" + |
| 3875 | " public class R2 playedBy T4127pd1c {\n" + |
| 3876 | " void rm2() { \n" + |
| 3877 | " System.out.print(\"O\"); \n" + |
| 3878 | " }\n" + |
| 3879 | " rm2 <- after bm;\n" + |
| 3880 | " }\n" + |
| 3881 | " precedence after R1, R2;\n" + |
| 3882 | " public static void main(String[] args) {\n" + |
| 3883 | " Team4127pd1c t = new Team4127pd1c();\n" + |
| 3884 | " t.activate();\n" + |
| 3885 | " T4127pd1c b = new T4127pd1c();\n" + |
| 3886 | " b.bm();\n" + |
| 3887 | " }\n" + |
| 3888 | "} \n" + |
| 3889 | " \n", |
| 3890 | "T4127pd1c.java", |
| 3891 | "\n" + |
| 3892 | "public class T4127pd1c {\n" + |
| 3893 | " void bm() { }\n" + |
| 3894 | "} \n" + |
| 3895 | " \n" |
| 3896 | }, |
| 3897 | "OK"); |
| 3898 | } |
| 3899 | |
| 3900 | // a team has two precedence declarations |
| 3901 | // 4.1.27-otjld-precedence-declaration-2 |
| 3902 | public void test4127_precedenceDeclaration2() { |
| 3903 | |
| 3904 | runConformTest( |
| 3905 | new String[] { |
| 3906 | "Team4127pd2.java", |
| 3907 | "\n" + |
| 3908 | "public team class Team4127pd2 {\n" + |
| 3909 | " public class R playedBy T4127pd2 {\n" + |
| 3910 | " void rm1() { \n" + |
| 3911 | " System.out.print(\"O\"); \n" + |
| 3912 | " }\n" + |
| 3913 | " void rm2() {\n" + |
| 3914 | " System.out.print(\"K\");\n" + |
| 3915 | " }\n" + |
| 3916 | " void rm3() {\n" + |
| 3917 | " System.out.print(\"!\");\n" + |
| 3918 | " }\n" + |
| 3919 | " b1: rm1 <- after bm;\n" + |
| 3920 | " b2: rm2 <- after bm;\n" + |
| 3921 | " b3: rm3 <- after bm;\n" + |
| 3922 | " }\n" + |
| 3923 | " precedence after R.b2, R.b1;\n" + |
| 3924 | " precedence after R.b3, R.b2;\n" + |
| 3925 | " public static void main(String[] args) {\n" + |
| 3926 | " Team4127pd2 t = new Team4127pd2();\n" + |
| 3927 | " t.activate();\n" + |
| 3928 | " T4127pd2 b = new T4127pd2();\n" + |
| 3929 | " b.bm();\n" + |
| 3930 | " }\n" + |
| 3931 | "} \n" + |
| 3932 | " \n", |
| 3933 | "T4127pd2.java", |
| 3934 | "\n" + |
| 3935 | "public class T4127pd2 {\n" + |
| 3936 | " void bm() { }\n" + |
| 3937 | "} \n" + |
| 3938 | " \n" |
| 3939 | }, |
| 3940 | "OK!"); |
| 3941 | } |
| 3942 | |
| 3943 | // a role has a precedence declaration |
| 3944 | // 4.1.27-otjld-precedence-declaration-3 |
| 3945 | public void test4127_precedenceDeclaration3() { |
| 3946 | |
| 3947 | runConformTest( |
| 3948 | new String[] { |
| 3949 | "Team4127pd3.java", |
| 3950 | "\n" + |
| 3951 | "public team class Team4127pd3 {\n" + |
| 3952 | " public class R playedBy T4127pd3 {\n" + |
| 3953 | " void rm1() { \n" + |
| 3954 | " System.out.print(\"O\"); \n" + |
| 3955 | " }\n" + |
| 3956 | " void rm2() {\n" + |
| 3957 | " System.out.print(\"K\");\n" + |
| 3958 | " }\n" + |
| 3959 | " b1: rm1 <- after bm;\n" + |
| 3960 | " b2: rm2 <- after bm;\n" + |
| 3961 | " precedence after b2, b1;\n" + |
| 3962 | " }\n" + |
| 3963 | " public static void main(String[] args) {\n" + |
| 3964 | " Team4127pd3 t = new Team4127pd3();\n" + |
| 3965 | " t.activate();\n" + |
| 3966 | " T4127pd3 b = new T4127pd3();\n" + |
| 3967 | " b.bm();\n" + |
| 3968 | " }\n" + |
| 3969 | "} \n" + |
| 3970 | " \n", |
| 3971 | "T4127pd3.java", |
| 3972 | "\n" + |
| 3973 | "public class T4127pd3 {\n" + |
| 3974 | " void bm() { }\n" + |
| 3975 | "} \n" + |
| 3976 | " \n" |
| 3977 | }, |
| 3978 | "OK"); |
| 3979 | } |
| 3980 | |
| 3981 | // a role has two precedence declarations |
| 3982 | // 4.1.27-otjld-precedence-declaration-4 |
| 3983 | public void test4127_precedenceDeclaration4() { |
| 3984 | |
| 3985 | runConformTest( |
| 3986 | new String[] { |
| 3987 | "Team4127pd4.java", |
| 3988 | "\n" + |
| 3989 | "public team class Team4127pd4 {\n" + |
| 3990 | " public class R playedBy T4127pd4 {\n" + |
| 3991 | " void rm1() { \n" + |
| 3992 | " System.out.print(\"O\"); \n" + |
| 3993 | " }\n" + |
| 3994 | " void rm2() {\n" + |
| 3995 | " System.out.print(\"K\");\n" + |
| 3996 | " }\n" + |
| 3997 | " void rm3() {\n" + |
| 3998 | " System.out.print(\"!\");\n" + |
| 3999 | " }\n" + |
| 4000 | " b1: rm1 <- after bm;\n" + |
| 4001 | " b2: rm2 <- after bm;\n" + |
| 4002 | " b3: rm3 <- after bm;\n" + |
| 4003 | " precedence after b2, b1;\n" + |
| 4004 | " precedence after b3, b2;\n" + |
| 4005 | " }\n" + |
| 4006 | " public static void main(String[] args) {\n" + |
| 4007 | " Team4127pd4 t = new Team4127pd4();\n" + |
| 4008 | " t.activate();\n" + |
| 4009 | " T4127pd4 b = new T4127pd4();\n" + |
| 4010 | " b.bm();\n" + |
| 4011 | " }\n" + |
| 4012 | "} \n" + |
| 4013 | " \n", |
| 4014 | "T4127pd4.java", |
| 4015 | "\n" + |
| 4016 | "public class T4127pd4 {\n" + |
| 4017 | " void bm() { }\n" + |
| 4018 | "} \n" + |
| 4019 | " \n" |
| 4020 | }, |
| 4021 | "OK!"); |
| 4022 | } |
| 4023 | |
| 4024 | // a team has a precedence declaration for replace bindings |
| 4025 | // 4.1.27-otjld-precedence-declaration-5 |
| 4026 | public void test4127_precedenceDeclaration5() { |
| 4027 | |
| 4028 | runConformTest( |
| 4029 | new String[] { |
| 4030 | "Team4127pd5.java", |
| 4031 | "\n" + |
| 4032 | "public team class Team4127pd5 {\n" + |
| 4033 | " public class R playedBy T4127pd5 {\n" + |
| 4034 | " callin void rm1() {\n" + |
| 4035 | " System.out.print(\"K\");\n" + |
| 4036 | " base.rm1();\n" + |
| 4037 | " System.out.print(\"Y\");\n" + |
| 4038 | " }\n" + |
| 4039 | " callin void rm2() { \n" + |
| 4040 | " System.out.print(\"O\");\n" + |
| 4041 | " base.rm2();\n" + |
| 4042 | " System.out.print(\"!\");\n" + |
| 4043 | " }\n" + |
| 4044 | " b1: rm1 <- replace bm;\n" + |
| 4045 | " b2: rm2 <- replace bm;\n" + |
| 4046 | " }\n" + |
| 4047 | " precedence R.b2, R.b1;\n" + |
| 4048 | " public static void main(String[] args) {\n" + |
| 4049 | " Team4127pd5 t = new Team4127pd5();\n" + |
| 4050 | " t.activate();\n" + |
| 4051 | " T4127pd5 b = new T4127pd5();\n" + |
| 4052 | " b.bm();\n" + |
| 4053 | " }\n" + |
| 4054 | "} \n" + |
| 4055 | " \n", |
| 4056 | "T4127pd5.java", |
| 4057 | "\n" + |
| 4058 | "public class T4127pd5 {\n" + |
| 4059 | " void bm() { System.out.print(\"A\");}\n" + |
| 4060 | "} \n" + |
| 4061 | " \n" |
| 4062 | }, |
| 4063 | "OKAY!"); |
| 4064 | } |
| 4065 | |
| 4066 | // a team has a precedence declaration for replace bindings - base call omitted |
| 4067 | // 4.1.27-otjld-precedence-declaration-6 |
| 4068 | public void test4127_precedenceDeclaration6() { |
| 4069 | |
| 4070 | runConformTest( |
| 4071 | new String[] { |
| 4072 | "T4127pd6Main.java", |
| 4073 | "\n" + |
| 4074 | "public class T4127pd6Main {\n" + |
| 4075 | " public static void main(String[] args) {\n" + |
| 4076 | " Team4127pd6 t = new Team4127pd6();\n" + |
| 4077 | " t.activate();\n" + |
| 4078 | " T4127pd6 b = new T4127pd6();\n" + |
| 4079 | " b.bm();\n" + |
| 4080 | " }\n" + |
| 4081 | "}\n" + |
| 4082 | " \n", |
| 4083 | "T4127pd6.java", |
| 4084 | "\n" + |
| 4085 | "public class T4127pd6 {\n" + |
| 4086 | " void bm() { System.out.print(\"A\");}\n" + |
| 4087 | "} \n" + |
| 4088 | " \n", |
| 4089 | "Team4127pd6.java", |
| 4090 | "\n" + |
| 4091 | "public team class Team4127pd6 {\n" + |
| 4092 | " public class R playedBy T4127pd6 {\n" + |
| 4093 | " callin void rm1() {\n" + |
| 4094 | " System.out.print(\"K\");\n" + |
| 4095 | " }\n" + |
| 4096 | " callin void rm2() { \n" + |
| 4097 | " System.out.print(\"O\");\n" + |
| 4098 | " base.rm2();\n" + |
| 4099 | " System.out.print(\"!\");\n" + |
| 4100 | " }\n" + |
| 4101 | " b1: rm1 <- replace bm;\n" + |
| 4102 | " b2: rm2 <- replace bm;\n" + |
| 4103 | " }\n" + |
| 4104 | " precedence R.b2, R.b1;\n" + |
| 4105 | "} \n" + |
| 4106 | " \n" |
| 4107 | }, |
| 4108 | "OK!"); |
| 4109 | } |
| 4110 | |
| 4111 | // a team has a precedence declaration for replace bindings - explicitly thrown LiftingVetoException |
| 4112 | // 4.1.27-otjld-precedence-declaration-7 |
| 4113 | public void test4127_precedenceDeclaration7() { |
| 4114 | |
| 4115 | runConformTest( |
| 4116 | new String[] { |
| 4117 | "Team4127pd7.java", |
| 4118 | "\n" + |
| 4119 | "public team class Team4127pd7 {\n" + |
| 4120 | " public class R playedBy T4127pd7 {\n" + |
| 4121 | " int count = 0;\n" + |
| 4122 | " R(T4127pd7 b) {\n" + |
| 4123 | " if (count%2==0) {\n" + |
| 4124 | " count++;\n" + |
| 4125 | " throw new org.objectteams.LiftingVetoException();\n" + |
| 4126 | " }\n" + |
| 4127 | " }\n" + |
| 4128 | " callin void rm1() {\n" + |
| 4129 | " System.out.print(\"K\");\n" + |
| 4130 | " base.rm1();\n" + |
| 4131 | " System.out.print(\"Y\");\n" + |
| 4132 | " }\n" + |
| 4133 | " callin void rm2() { \n" + |
| 4134 | " System.out.print(\"O\");\n" + |
| 4135 | " base.rm2();\n" + |
| 4136 | " System.out.print(\"!\");\n" + |
| 4137 | " }\n" + |
| 4138 | " b1: rm1 <- replace bm;\n" + |
| 4139 | " b2: rm2 <- replace bm;\n" + |
| 4140 | " }\n" + |
| 4141 | " precedence R.b2, R.b1;\n" + |
| 4142 | " public static void main(String[] args) {\n" + |
| 4143 | " Team4127pd7 t = new Team4127pd7();\n" + |
| 4144 | " t.activate();\n" + |
| 4145 | " T4127pd7 b = new T4127pd7();\n" + |
| 4146 | " b.bm();\n" + |
| 4147 | " }\n" + |
| 4148 | "} \n" + |
| 4149 | " \n", |
| 4150 | "T4127pd7.java", |
| 4151 | "\n" + |
| 4152 | "public class T4127pd7 {\n" + |
| 4153 | " void bm() { System.out.print(\"A\");}\n" + |
| 4154 | "} \n" + |
| 4155 | " \n" |
| 4156 | }, |
| 4157 | "KAY"); |
| 4158 | } |
| 4159 | |
| 4160 | // a team has a precedence declaration for replace bindings - guard forbids lifting |
| 4161 | // 4.1.27-otjld-precedence-declaration-8 |
| 4162 | public void test4127_precedenceDeclaration8() { |
| 4163 | |
| 4164 | runConformTest( |
| 4165 | new String[] { |
| 4166 | "Team4127pd8.java", |
| 4167 | "\n" + |
| 4168 | "public team class Team4127pd8 {\n" + |
| 4169 | " public class R playedBy T4127pd8 {\n" + |
| 4170 | " callin void rm1() {\n" + |
| 4171 | " System.out.print(\"K\");\n" + |
| 4172 | " base.rm1();\n" + |
| 4173 | " System.out.print(\"Y\");\n" + |
| 4174 | " }\n" + |
| 4175 | " callin void rm2() base when (false) { \n" + |
| 4176 | " System.out.print(\"O\");\n" + |
| 4177 | " base.rm2();\n" + |
| 4178 | " System.out.print(\"!\");\n" + |
| 4179 | " }\n" + |
| 4180 | " b1: rm1 <- replace bm;\n" + |
| 4181 | " b2: rm2 <- replace bm;\n" + |
| 4182 | " }\n" + |
| 4183 | " precedence R.b2, R.b1;\n" + |
| 4184 | " public static void main(String[] args) {\n" + |
| 4185 | " Team4127pd8 t = new Team4127pd8();\n" + |
| 4186 | " t.activate();\n" + |
| 4187 | " T4127pd8 b = new T4127pd8();\n" + |
| 4188 | " b.bm();\n" + |
| 4189 | " }\n" + |
| 4190 | "} \n" + |
| 4191 | " \n", |
| 4192 | "T4127pd8.java", |
| 4193 | "\n" + |
| 4194 | "public class T4127pd8 {\n" + |
| 4195 | " void bm() { System.out.print(\"A\");}\n" + |
| 4196 | "} \n" + |
| 4197 | " \n" |
| 4198 | }, |
| 4199 | "KAY"); |
| 4200 | } |
| 4201 | |
| 4202 | // two teams have precedence declarations for replace bindings - guard forbids lifting |
| 4203 | // 4.1.27-otjld-precedence-declaration-9 |
| 4204 | public void test4127_precedenceDeclaration9() { |
| 4205 | |
| 4206 | runConformTest( |
| 4207 | new String[] { |
| 4208 | "Team4127pd9.java", |
| 4209 | "\n" + |
| 4210 | "public team class Team4127pd9 {\n" + |
| 4211 | " public class R playedBy T4127pd9 {\n" + |
| 4212 | " callin void rm1() {\n" + |
| 4213 | " System.out.print(\"K\");\n" + |
| 4214 | " base.rm1();\n" + |
| 4215 | " System.out.print(\"Y\");\n" + |
| 4216 | " }\n" + |
| 4217 | " callin void rm2() { \n" + |
| 4218 | " System.out.print(\"O\");\n" + |
| 4219 | " base.rm2();\n" + |
| 4220 | " System.out.print(\"!\");\n" + |
| 4221 | " }\n" + |
| 4222 | " b1: rm1 <- replace bm;\n" + |
| 4223 | " b2: rm2 <- replace bm;\n" + |
| 4224 | " }\n" + |
| 4225 | " precedence R.b2, R.b1;\n" + |
| 4226 | " public static void main(String[] args) {\n" + |
| 4227 | " Team4127pd9 t = new Team4127pd9();\n" + |
| 4228 | " t.activate();\n" + |
| 4229 | " Team4127pd9_2 t2 = new Team4127pd9_2();\n" + |
| 4230 | " t2.activate();\n" + |
| 4231 | " T4127pd9 b = new T4127pd9();\n" + |
| 4232 | " b.bm();\n" + |
| 4233 | " }\n" + |
| 4234 | "} \n" + |
| 4235 | " \n", |
| 4236 | "T4127pd9.java", |
| 4237 | "\n" + |
| 4238 | "public class T4127pd9 {\n" + |
| 4239 | " void bm() { System.out.print(\"A\");}\n" + |
| 4240 | "} \n" + |
| 4241 | " \n", |
| 4242 | "Team4127pd9_2.java", |
| 4243 | "\n" + |
| 4244 | "public team class Team4127pd9_2 {\n" + |
| 4245 | " public class R playedBy T4127pd9 base when (false) {\n" + |
| 4246 | " callin void rm1() {\n" + |
| 4247 | " System.out.print(\"NOT\");\n" + |
| 4248 | " base.rm1();\n" + |
| 4249 | " }\n" + |
| 4250 | " callin void rm2() { \n" + |
| 4251 | " base.rm2();\n" + |
| 4252 | " System.out.print(\"!\");\n" + |
| 4253 | " }\n" + |
| 4254 | " b1: rm1 <- replace bm;\n" + |
| 4255 | " b2: rm2 <- replace bm;\n" + |
| 4256 | " }\n" + |
| 4257 | " precedence R.b2, R.b1;\n" + |
| 4258 | "} \n" + |
| 4259 | " \n" |
| 4260 | }, |
| 4261 | "OKAY!"); |
| 4262 | } |
| 4263 | |
| 4264 | // a team has a precedence declaration - subteam adds another one |
| 4265 | // 4.1.27-otjld-precedence-declaration-10 |
| 4266 | public void test4127_precedenceDeclaration10() { |
| 4267 | |
| 4268 | runConformTest( |
| 4269 | new String[] { |
| 4270 | "Team4127pd10_2.java", |
| 4271 | "\n" + |
| 4272 | "public team class Team4127pd10_2 extends Team4127pd10_1 {\n" + |
| 4273 | " public class R {\n" + |
| 4274 | " void rm3() {\n" + |
| 4275 | " System.out.print(\"!\");\n" + |
| 4276 | " }\n" + |
| 4277 | " b3: rm3 <- after bm;\n" + |
| 4278 | " }\n" + |
| 4279 | " precedence after R.b3, R.b1;\n" + |
| 4280 | " public static void main(String[] args) {\n" + |
| 4281 | " Team4127pd10_2 t = new Team4127pd10_2();\n" + |
| 4282 | " t.activate();\n" + |
| 4283 | " T4127pd10 b = new T4127pd10();\n" + |
| 4284 | " b.bm();\n" + |
| 4285 | " }\n" + |
| 4286 | "} \n" + |
| 4287 | " \n", |
| 4288 | "T4127pd10.java", |
| 4289 | "\n" + |
| 4290 | "public class T4127pd10 {\n" + |
| 4291 | " void bm() { }\n" + |
| 4292 | "} \n" + |
| 4293 | " \n", |
| 4294 | "Team4127pd10_1.java", |
| 4295 | "\n" + |
| 4296 | "public team class Team4127pd10_1 {\n" + |
| 4297 | " public class R playedBy T4127pd10 {\n" + |
| 4298 | " void rm1() {\n" + |
| 4299 | " System.out.print(\"K\");\n" + |
| 4300 | " }\n" + |
| 4301 | " void rm2() { \n" + |
| 4302 | " System.out.print(\"O\"); \n" + |
| 4303 | " }\n" + |
| 4304 | " b1: rm1 <- after bm;\n" + |
| 4305 | " b2: rm2 <- after bm;\n" + |
| 4306 | " }\n" + |
| 4307 | " precedence after R.b1, R.b2;\n" + |
| 4308 | "}\n" + |
| 4309 | " \n" |
| 4310 | }, |
| 4311 | "OK!"); |
| 4312 | } |
| 4313 | |
| 4314 | // a team has a precedence declaration - subteam adds another one - within packages |
| 4315 | // 4.1.27-otjld-precedence-declaration-10p |
| 4316 | public void test4127_precedenceDeclaration10p() { |
| 4317 | |
| 4318 | runConformTest( |
| 4319 | new String[] { |
| 4320 | "p2/Team4127pd10p_2.java", |
| 4321 | "\n" + |
| 4322 | "package p2;\n" + |
| 4323 | "public team class Team4127pd10p_2 extends p1.Team4127pd10p_1 {\n" + |
| 4324 | " public class R {\n" + |
| 4325 | " void rm3() {\n" + |
| 4326 | " System.out.print(\"!\");\n" + |
| 4327 | " }\n" + |
| 4328 | " b3: rm3 <- after bm;\n" + |
| 4329 | " }\n" + |
| 4330 | " precedence after R.b3, R.b1;\n" + |
| 4331 | " public static void main(String[] args) {\n" + |
| 4332 | " Team4127pd10p_2 t = new Team4127pd10p_2();\n" + |
| 4333 | " t.activate();\n" + |
| 4334 | " p1.T4127pd10p b = new p1.T4127pd10p();\n" + |
| 4335 | " b.bm();\n" + |
| 4336 | " }\n" + |
| 4337 | "} \n" + |
| 4338 | " \n", |
| 4339 | "p1/T4127pd10p.java", |
| 4340 | "\n" + |
| 4341 | "package p1;\n" + |
| 4342 | "public class T4127pd10p {\n" + |
| 4343 | " public void bm() { }\n" + |
| 4344 | "} \n" + |
| 4345 | " \n", |
| 4346 | "p1/Team4127pd10p_1.java", |
| 4347 | "\n" + |
| 4348 | "package p1;\n" + |
| 4349 | "public team class Team4127pd10p_1 {\n" + |
| 4350 | " public class R playedBy T4127pd10p {\n" + |
| 4351 | " void rm1() {\n" + |
| 4352 | " System.out.print(\"K\");\n" + |
| 4353 | " }\n" + |
| 4354 | " void rm2() { \n" + |
| 4355 | " System.out.print(\"O\"); \n" + |
| 4356 | " }\n" + |
| 4357 | " b1: rm1 <- after bm;\n" + |
| 4358 | " b2: rm2 <- after bm;\n" + |
| 4359 | " }\n" + |
| 4360 | " precedence after R.b1, R.b2;\n" + |
| 4361 | "}\n" + |
| 4362 | " \n" |
| 4363 | }, |
| 4364 | "OK!"); |
| 4365 | } |
| 4366 | |
| 4367 | // a nested team has a precedence declaration |
| 4368 | // 4.1.27-otjld-precedence-declaration-11 |
| 4369 | public void test4127_precedenceDeclaration11() { |
| 4370 | |
| 4371 | runConformTest( |
| 4372 | new String[] { |
| 4373 | "Team4127pd11_2.java", |
| 4374 | "\n" + |
| 4375 | "public team class Team4127pd11_2 extends Team4127pd11_1 {\n" + |
| 4376 | " public static void main(String[] args) {\n" + |
| 4377 | " new Team4127pd11_1();\n" + |
| 4378 | " T4127pd11 b = new T4127pd11();\n" + |
| 4379 | " b.bm();\n" + |
| 4380 | " }\n" + |
| 4381 | "} \n" + |
| 4382 | " \n", |
| 4383 | "T4127pd11.java", |
| 4384 | "\n" + |
| 4385 | "public class T4127pd11 {\n" + |
| 4386 | " void bm() { }\n" + |
| 4387 | "} \n" + |
| 4388 | " \n", |
| 4389 | "Team4127pd11_1.java", |
| 4390 | "\n" + |
| 4391 | "public team class Team4127pd11_1 {\n" + |
| 4392 | " public team class InnerT {\n" + |
| 4393 | " public class R playedBy T4127pd11 {\n" + |
| 4394 | " void rm1() {\n" + |
| 4395 | " System.out.print(\"K\");\n" + |
| 4396 | " }\n" + |
| 4397 | " void rm2() { \n" + |
| 4398 | " System.out.print(\"O\"); \n" + |
| 4399 | " }\n" + |
| 4400 | " b1: rm1 <- after bm;\n" + |
| 4401 | " b2: rm2 <- after bm;\n" + |
| 4402 | " }\n" + |
| 4403 | " precedence after R.b1, R.b2;\n" + |
| 4404 | " \n" + |
| 4405 | " }\n" + |
| 4406 | " public Team4127pd11_1 () {\n" + |
| 4407 | " InnerT it = new InnerT();\n" + |
| 4408 | " it.activate();\n" + |
| 4409 | " }\n" + |
| 4410 | "}\n" + |
| 4411 | " \n" |
| 4412 | }, |
| 4413 | "OK"); |
| 4414 | } |
| 4415 | |
| 4416 | // a nested team has a precedence declaration - in a package |
| 4417 | // 4.1.27-otjld-precedence-declaration-11p |
| 4418 | public void test4127_precedenceDeclaration11p() { |
| 4419 | |
| 4420 | runConformTest( |
| 4421 | new String[] { |
| 4422 | "p2/Team4127pd11p_2.java", |
| 4423 | "\n" + |
| 4424 | "package p2;\n" + |
| 4425 | "import p1.Team4127pd11p_1;\n" + |
| 4426 | "public team class Team4127pd11p_2 extends Team4127pd11p_1 {\n" + |
| 4427 | " public static void main(String[] args) {\n" + |
| 4428 | " new p1.Team4127pd11p_1();\n" + |
| 4429 | " p1.T4127pd11p b = new p1.T4127pd11p();\n" + |
| 4430 | " b.bm();\n" + |
| 4431 | " }\n" + |
| 4432 | "} \n" + |
| 4433 | " \n", |
| 4434 | "p1/T4127pd11p.java", |
| 4435 | "\n" + |
| 4436 | "package p1;\n" + |
| 4437 | "public class T4127pd11p {\n" + |
| 4438 | " public void bm() { }\n" + |
| 4439 | "} \n" + |
| 4440 | " \n", |
| 4441 | "p1/Team4127pd11p_1.java", |
| 4442 | "\n" + |
| 4443 | "package p1;\n" + |
| 4444 | "public team class Team4127pd11p_1 {\n" + |
| 4445 | " protected team class InnerT {\n" + |
| 4446 | " public class R playedBy T4127pd11p {\n" + |
| 4447 | " void rm1() {\n" + |
| 4448 | " System.out.print(\"K\");\n" + |
| 4449 | " }\n" + |
| 4450 | " void rm2() { \n" + |
| 4451 | " System.out.print(\"O\"); \n" + |
| 4452 | " }\n" + |
| 4453 | " b1: rm1 <- after bm;\n" + |
| 4454 | " b2: rm2 <- after bm;\n" + |
| 4455 | " }\n" + |
| 4456 | " precedence after R.b1, R.b2;\n" + |
| 4457 | " \n" + |
| 4458 | " }\n" + |
| 4459 | " public Team4127pd11p_1 () {\n" + |
| 4460 | " InnerT it = new InnerT();\n" + |
| 4461 | " it.activate();\n" + |
| 4462 | " }\n" + |
| 4463 | "}\n" + |
| 4464 | " \n" |
| 4465 | }, |
| 4466 | "OK"); |
| 4467 | } |
| 4468 | |
| 4469 | // a nested team has a precedence declaration - in a package - compile in one go |
| 4470 | // 4.1.27-otjld-precedence-declaration-11P |
| 4471 | public void test4127_precedenceDeclaration11P() { |
| 4472 | |
| 4473 | runConformTest( |
| 4474 | new String[] { |
| 4475 | "p2/Team4127pd11P_2.java", |
| 4476 | "\n" + |
| 4477 | "package p2;\n" + |
| 4478 | "import p1.Team4127pd11P_1;\n" + |
| 4479 | "public team class Team4127pd11P_2 extends Team4127pd11P_1 {\n" + |
| 4480 | " public static void main(String[] args) {\n" + |
| 4481 | " new p1.Team4127pd11P_1();\n" + |
| 4482 | " p1.T4127pd11P b = new p1.T4127pd11P();\n" + |
| 4483 | " b.bm();\n" + |
| 4484 | " }\n" + |
| 4485 | "}\n" + |
| 4486 | " \n", |
| 4487 | "p1/T4127pd11P.java", |
| 4488 | "\n" + |
| 4489 | "package p1;\n" + |
| 4490 | "public class T4127pd11P {\n" + |
| 4491 | " public void bm() { }\n" + |
| 4492 | "}\n" + |
| 4493 | " \n", |
| 4494 | "p1/Team4127pd11P_1.java", |
| 4495 | "\n" + |
| 4496 | "package p1;\n" + |
| 4497 | "public team class Team4127pd11P_1 {\n" + |
| 4498 | " protected team class InnerT {\n" + |
| 4499 | " public class R playedBy T4127pd11P {\n" + |
| 4500 | " void rm1() {\n" + |
| 4501 | " System.out.print(\"K\");\n" + |
| 4502 | " }\n" + |
| 4503 | " void rm2() {\n" + |
| 4504 | " System.out.print(\"O\");\n" + |
| 4505 | " }\n" + |
| 4506 | " b1: rm1 <- after bm;\n" + |
| 4507 | " b2: rm2 <- after bm;\n" + |
| 4508 | " }\n" + |
| 4509 | " precedence after R.b1, R.b2;\n" + |
| 4510 | "\n" + |
| 4511 | " }\n" + |
| 4512 | " public Team4127pd11P_1 () {\n" + |
| 4513 | " InnerT it = new InnerT();\n" + |
| 4514 | " it.activate();\n" + |
| 4515 | " }\n" + |
| 4516 | "}\n" + |
| 4517 | " \n" |
| 4518 | }, |
| 4519 | "OK"); |
| 4520 | } |
| 4521 | |
| 4522 | // a precedence is not needed because lifting has no overlap (witness for TPX-418 comment 2) |
| 4523 | // 4.1.27-otjld-precedence-declaration-12 |
| 4524 | public void test4127_precedenceDeclaration12() { |
| 4525 | |
| 4526 | runConformTest( |
| 4527 | new String[] { |
| 4528 | "Team4127pd12.java", |
| 4529 | "\n" + |
| 4530 | "public team class Team4127pd12 {\n" + |
| 4531 | " protected class R1 playedBy T4127pd12_1 {\n" + |
| 4532 | " void rm() { System.out.print(\"?\"); }\n" + |
| 4533 | " rm <- after bm;\n" + |
| 4534 | " }\n" + |
| 4535 | " protected class R2 playedBy T4127pd12_2 {\n" + |
| 4536 | " void rm() { System.out.print(\"!\"); }\n" + |
| 4537 | " rm <- after bm;\n" + |
| 4538 | " }\n" + |
| 4539 | " public static void main(String[] args) {\n" + |
| 4540 | " new Team4127pd12().activate();\n" + |
| 4541 | " new T4127pd12_1().bm();\n" + |
| 4542 | " new T4127pd12_2().bm();\n" + |
| 4543 | " }\n" + |
| 4544 | "}\n" + |
| 4545 | " \n", |
| 4546 | "T4127pd12_0.java", |
| 4547 | "\n" + |
| 4548 | "public class T4127pd12_0 {\n" + |
| 4549 | " void bm() { System.out.print(\"O\"); }\n" + |
| 4550 | "}\n" + |
| 4551 | " \n", |
| 4552 | "T4127pd12_1.java", |
| 4553 | "\n" + |
| 4554 | "public class T4127pd12_1 extends T4127pd12_0 {\n" + |
| 4555 | "}\n" + |
| 4556 | " \n", |
| 4557 | "T4127pd12_2.java", |
| 4558 | "\n" + |
| 4559 | "public class T4127pd12_2 extends T4127pd12_0 {\n" + |
| 4560 | " void bm() { System.out.print(\"K\"); }\n" + |
| 4561 | "}\n" + |
| 4562 | " \n" |
| 4563 | }, |
| 4564 | "O?K!"); |
| 4565 | } |
| 4566 | |
| 4567 | // precedence for two after callin bindings, missing "after" modifier |
| 4568 | public void test4127_precedenceDeclaration13() { |
| 4569 | runNegativeTest( |
| 4570 | new String[] { |
| 4571 | "Team4127pd13.java", |
| 4572 | "public team class Team4127pd13 {\n" + |
| 4573 | " protected class R playedBy T4127pd13 {\n" + |
| 4574 | " c1: k <- after test;\n" + |
| 4575 | " c2: bang <- after test;\n" + |
| 4576 | " void k() { System.out.print(\"K\"); }\n" + |
| 4577 | " void bang() { System.out.print(\"!\"); }\n" + |
| 4578 | " precedence c2, c1;\n" + |
| 4579 | " }\n" + |
| 4580 | "}\n", |
| 4581 | "T4127pd13.java", |
| 4582 | "public class T4127pd13 {\n" + |
| 4583 | " void test() { System.out.print(\"O\"); }\n" + |
| 4584 | "}\n" |
| 4585 | }, |
| 4586 | "----------\n" + |
| 4587 | "1. ERROR in Team4127pd13.java (at line 7)\n" + |
| 4588 | " precedence c2, c1;\n" + |
| 4589 | " ^^\n" + |
| 4590 | "\'precedence\' declaration for \'after\' binding must be specified as \'precedence after\' (OTJLD 4.8(a)).\n" + |
| 4591 | "----------\n" + |
| 4592 | "2. ERROR in Team4127pd13.java (at line 7)\n" + |
| 4593 | " precedence c2, c1;\n" + |
| 4594 | " ^^\n" + |
| 4595 | "\'precedence\' declaration for \'after\' binding must be specified as \'precedence after\' (OTJLD 4.8(a)).\n" + |
| 4596 | "----------\n"); |
| 4597 | } |
| 4598 | |
| 4599 | // precedence after for two callin bindings, one without the "after" modifier |
| 4600 | public void test4127_precedenceDeclaration14() { |
| 4601 | runNegativeTest( |
| 4602 | new String[] { |
| 4603 | "Team4127pd14.java", |
| 4604 | "public team class Team4127pd14 {\n" + |
| 4605 | " protected class R playedBy T4127pd14 {\n" + |
| 4606 | " c1: k <- after test;\n" + |
| 4607 | " c2: bang <- before test;\n" + |
| 4608 | " void k() { System.out.print(\"K\"); }\n" + |
| 4609 | " void bang() { System.out.print(\"!\"); }\n" + |
| 4610 | " precedence after c2, c1;\n" + |
| 4611 | " }\n" + |
| 4612 | "}\n", |
| 4613 | "T4127pd14.java", |
| 4614 | "public class T4127pd14 {\n" + |
| 4615 | " void test() { System.out.print(\"O\"); }\n" + |
| 4616 | "}\n" |
| 4617 | }, |
| 4618 | "----------\n" + |
| 4619 | "1. ERROR in Team4127pd14.java (at line 7)\n" + |
| 4620 | " precedence after c2, c1;\n" + |
| 4621 | " ^^\n" + |
| 4622 | "\'precedence after\' declaration cannot refer to \'before\' bindings (OTJLD 4.8(a)).\n" + |
| 4623 | "----------\n"); |
| 4624 | } |
| 4625 | |
| 4626 | // merging precedence declarations from two nesting levels: |
| 4627 | public void test4127_precedenceDeclaration15() { |
| 4628 | runConformTest( |
| 4629 | new String[] { |
| 4630 | "Team4127pd15.java", |
| 4631 | "public team class Team4127pd15 {\n" + |
| 4632 | " precedence MyRoleB.bl1, MyRoleA;\n" + |
| 4633 | " protected class MyRoleB playedBy T4127pd15 {\n" + |
| 4634 | " precedence bl1, bl2;\n" + |
| 4635 | " void rm() {\n" + |
| 4636 | " System.out.print(\"1\");\n" + |
| 4637 | " }\n" + |
| 4638 | " bl1: rm <- before bm;\n" + |
| 4639 | " void rm2() {\n" + |
| 4640 | " System.out.print(\"2\");\n" + |
| 4641 | " }\n" + |
| 4642 | " bl2: rm2 <- before bm;\n" + |
| 4643 | " }\n" + |
| 4644 | " protected class MyRoleA playedBy T4127pd15 {\n" + |
| 4645 | " void rm() {\n" + |
| 4646 | " System.out.print(\"3\");\n" + |
| 4647 | " }\n" + |
| 4648 | " rm <- before bm;\n" + |
| 4649 | " }\n" + |
| 4650 | " public static void main(String... args) {\n" + |
| 4651 | " Team4127pd15 t = new Team4127pd15();\n" + |
| 4652 | " t.activate();\n" + |
| 4653 | " T4127pd15 b = new T4127pd15();\n" + |
| 4654 | " b.bm();\n" + |
| 4655 | " }\n" + |
| 4656 | "}\n", |
| 4657 | "T4127pd15.java", |
| 4658 | "public class T4127pd15 {\n" + |
| 4659 | " void bm() {\n" + |
| 4660 | " System.out.print(\"!\");\n" + |
| 4661 | " }\n" + |
| 4662 | "}\n" |
| 4663 | }, |
| 4664 | "123!"); |
| 4665 | } |
| 4666 | |
| 4667 | // merging precedence declarations from the same nesting levels: |
| 4668 | public void test4127_precedenceDeclaration16() { |
| 4669 | runConformTest( |
| 4670 | new String[] { |
| 4671 | "Team4127pd16.java", |
| 4672 | "public team class Team4127pd16 {\n" + |
| 4673 | " protected class MyRoleB playedBy T4127pd16 {\n" + |
| 4674 | " precedence bl1, bl2;\n" + |
| 4675 | " precedence bl1, bl3;\n" + |
| 4676 | " void rm() {\n" + |
| 4677 | " System.out.print(\"1\");\n" + |
| 4678 | " }\n" + |
| 4679 | " bl1: rm <- before bm;\n" + |
| 4680 | " void rm3() {\n" + |
| 4681 | " System.out.print(\"3\");\n" + |
| 4682 | " }\n" + |
| 4683 | " bl3: rm3 <- before bm;\n" + |
| 4684 | " void rm2() {\n" + |
| 4685 | " System.out.print(\"2\");\n" + |
| 4686 | " }\n" + |
| 4687 | " bl2: rm2 <- before bm;\n" + |
| 4688 | " }\n" + |
| 4689 | " public static void main(String... args) {\n" + |
| 4690 | " Team4127pd16 t = new Team4127pd16();\n" + |
| 4691 | " t.activate();\n" + |
| 4692 | " T4127pd16 b = new T4127pd16();\n" + |
| 4693 | " b.bm();\n" + |
| 4694 | " }\n" + |
| 4695 | "}\n", |
| 4696 | "T4127pd16.java", |
| 4697 | "public class T4127pd16 {\n" + |
| 4698 | " void bm() {\n" + |
| 4699 | " System.out.print(\"!\");\n" + |
| 4700 | " }\n" + |
| 4701 | "}\n" |
| 4702 | }, |
| 4703 | "123!"); |
| 4704 | } |
| 4705 | |
| 4706 | // merging precedence declarations from two nesting levels |
| 4707 | // Bug 316659 - [compiler] NPE in PrecedenceBinding.hasCommonBaseMethod |
| 4708 | public void test4127_precedenceDeclaration17() { |
| 4709 | runNegativeTest( |
| 4710 | new String[] { |
| 4711 | "Team4127pd17.java", |
| 4712 | "public team class Team4127pd17 {\n" + |
| 4713 | " precedence MyRoleB.bl1, MyRoleA;\n" + |
| 4714 | " protected class MyRoleB playedBy T4127pd17 {\n" + |
| 4715 | " precedence MyRoleB.bl1, MyRoleB.bl2;\n" + |
| 4716 | " void rm() {\n" + |
| 4717 | " System.out.print(\"1\");\n" + |
| 4718 | " }\n" + |
| 4719 | " bl1: rm <- before bm;\n" + |
| 4720 | " void rm2() {\n" + |
| 4721 | " System.out.print(\"2\");\n" + |
| 4722 | " }\n" + |
| 4723 | " bl2: rm2 <- before bm;\n" + |
| 4724 | " }\n" + |
| 4725 | " protected class MyRoleA playedBy T4127pd17 {\n" + |
| 4726 | " void rm() {\n" + |
| 4727 | " System.out.print(\"3\");\n" + |
| 4728 | " }\n" + |
| 4729 | " rm <- before bm;\n" + |
| 4730 | " }\n" + |
| 4731 | " public static void main(String... args) {\n" + |
| 4732 | " Team4127pd17 t = new Team4127pd17();\n" + |
| 4733 | " t.activate();\n" + |
| 4734 | " T4127pd17 b = new T4127pd17();\n" + |
| 4735 | " b.bm();\n" + |
| 4736 | " }\n" + |
| 4737 | "}\n", |
| 4738 | "T4127pd17.java", |
| 4739 | "public class T4127pd17 {\n" + |
| 4740 | " void bm() {\n" + |
| 4741 | " System.out.print(\"!\");\n" + |
| 4742 | " }\n" + |
| 4743 | "}\n" |
| 4744 | }, |
| 4745 | "----------\n" + |
| 4746 | "1. ERROR in Team4127pd17.java (at line 4)\n" + |
| 4747 | " precedence MyRoleB.bl1, MyRoleB.bl2;\n" + |
| 4748 | " ^^^^^^^^^^^\n" + |
| 4749 | "MyRoleB cannot be resolved to a type\n" + |
| 4750 | "----------\n" + |
| 4751 | "2. ERROR in Team4127pd17.java (at line 4)\n" + |
| 4752 | " precedence MyRoleB.bl1, MyRoleB.bl2;\n" + |
| 4753 | " ^^^^^^^^^^^\n" + |
| 4754 | "MyRoleB cannot be resolved to a type\n" + |
| 4755 | "----------\n" + |
| 4756 | "3. ERROR in Team4127pd17.java (at line 8)\n" + |
| 4757 | " bl1: rm <- before bm;\n" + |
| 4758 | " ^^^\n" + |
| 4759 | "\'before\' callin bindings Team4127pd17.MyRoleB.bl1 and Team4127pd17.MyRoleB.bl2 refer to the same base method; must declare precedence of these bindings (OTJLD 4.8).\n" + |
| 4760 | "----------\n" + |
| 4761 | "4. ERROR in Team4127pd17.java (at line 18)\n" + |
| 4762 | " rm <- before bm;\n" + |
| 4763 | " ^^\n" + |
| 4764 | "\'before\' callin bindings Team4127pd17.MyRoleA.<Team4127pd17:18,2> and Team4127pd17.MyRoleB.bl2 refer to the same base method; must declare precedence of these bindings (OTJLD 4.8).\n" + |
| 4765 | "----------\n"); |
| 4766 | } |
| 4767 | |
Stephan Herrmann | de4a080 | 2011-01-04 21:06:39 +0000 | [diff] [blame] | 4768 | // Bug 332893 - Class Precedence not working between Role callin and SubRole callin |
| 4769 | public void test4127_precedenceDeclaration18 () { |
| 4770 | runNegativeTest( |
| 4771 | new String[] { |
| 4772 | "PrecBug.java", |
| 4773 | "public team class PrecBug {\n" + |
| 4774 | " precedence after RA.RB, RA;\n" + |
| 4775 | " protected team class RA playedBy A {\n" + |
| 4776 | " void some(String v) <- after void myMethod2()\n" + |
| 4777 | " with { v <- \"RA\" }\n" + |
| 4778 | " void some(String v) {\n" + |
| 4779 | " System.out.print(\"some\"+v);\n" + |
| 4780 | " }\n" + |
| 4781 | " protected class RB playedBy B {\n" + |
| 4782 | " void some(String v) <- after void myMethod2()" + |
| 4783 | " with { v <- \"RB\" }\n" + |
| 4784 | " }\n" + |
| 4785 | " }\n" + |
| 4786 | " public PrecBug(A as RA a) {\n" + |
| 4787 | " a.activate();\n" + |
| 4788 | " }\n" + |
| 4789 | " public static void main(String... args) {\n" + |
| 4790 | " B b = new B();\n" + |
| 4791 | " new PrecBug(b).activate();\n" + |
| 4792 | " new B().myMethod2();\n" + |
| 4793 | " }\n" + |
| 4794 | "}\n", |
| 4795 | "A.java", |
| 4796 | "public class A {\n" + |
| 4797 | " void myMethod2() {}\n" + |
| 4798 | "}\n", |
| 4799 | "B.java", |
| 4800 | "public class B extends A {\n" + |
| 4801 | "}\n" |
| 4802 | }, |
| 4803 | "----------\n" + |
| 4804 | "1. ERROR in PrecBug.java (at line 2)\n" + |
| 4805 | " precedence after RA.RB, RA;\n" + |
| 4806 | " ^^^^^^^^^^\n" + |
| 4807 | "\'precedence\' declaration can only refer to direct role classes, however PrecBug.RA.RB is a nested role of team PrecBug.RA (OTJLD 4.8).\n" + |
| 4808 | "----------\n"); |
| 4809 | } |
Stephan Herrmann | df8e4e0 | 2011-04-16 11:56:30 +0000 | [diff] [blame] | 4810 | |
| 4811 | // Bug 335777 - [compiler] don't flag missing precedence if different enclosing teams |
| 4812 | public void test4127_precedenceDeclaration19 () { |
| 4813 | runConformTest( |
| 4814 | new String[] { |
| 4815 | "PrecBug19.java", |
| 4816 | "public team class PrecBug19 {\n" + |
| 4817 | " protected team class RA playedBy A {\n" + |
| 4818 | " void some(String v) <- before void myMethod2()\n" + |
| 4819 | " with { v <- \"RA\" }\n" + |
| 4820 | " void some(String v) <- after void myMethod2()\n" + |
| 4821 | " with { v <- \"RA\" }\n" + |
| 4822 | " void some(String v) {\n" + |
| 4823 | " System.out.print(\"some\"+v);\n" + |
| 4824 | " }\n" + |
| 4825 | " protected class RB playedBy B {\n" + |
| 4826 | " void some(String v) <- before void myMethod2()" + |
| 4827 | " with { v <- \"RB\" }\n" + |
| 4828 | " void some(String v) <- after void myMethod2()" + |
| 4829 | " with { v <- \"RB\" }\n" + |
| 4830 | " }\n" + |
| 4831 | " }\n" + |
| 4832 | " public PrecBug19(A as RA a) {\n" + |
| 4833 | " a.activate();\n" + |
| 4834 | " }\n" + |
| 4835 | " public static void main(String... args) {\n" + |
| 4836 | " B b = new B();\n" + |
| 4837 | " new PrecBug19(b).activate();\n" + |
| 4838 | " new B().myMethod2();\n" + |
| 4839 | " }\n" + |
| 4840 | "}\n", |
| 4841 | "A.java", |
| 4842 | "public class A {\n" + |
| 4843 | " void myMethod2() { System.out.print(\"-\"); }\n" + |
| 4844 | "}\n", |
| 4845 | "B.java", |
| 4846 | "public class B extends A {\n" + |
| 4847 | "}\n" |
| 4848 | }, |
| 4849 | "someRAsomeRB-someRBsomeRA"); |
| 4850 | } |
| 4851 | |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 4852 | // a regular class has a precedence declaration |
| 4853 | // 4.1.28-otjld-invalid-precedence-declaration-1 |
| 4854 | public void test4128_invalidPrecedenceDeclaration1() { |
| 4855 | runNegativeTestMatching( |
| 4856 | new String[] { |
| 4857 | "T4128ipd1.java", |
| 4858 | "\n" + |
| 4859 | "public class T4128ipd1 {\n" + |
| 4860 | " precedence R.b1, R.b2;\n" + |
| 4861 | "} \n" + |
| 4862 | " \n" |
| 4863 | }, |
| 4864 | "A.0.1"); |
| 4865 | } |
| 4866 | |
| 4867 | // a team has a precedence declaration - no such callin binding |
| 4868 | // 4.1.28-otjld-invalid-precedence-declaration-2 |
| 4869 | public void test4128_invalidPrecedenceDeclaration2() { |
| 4870 | runNegativeTestMatching( |
| 4871 | new String[] { |
| 4872 | "Team4128ipd2.java", |
| 4873 | "\n" + |
| 4874 | "public team class Team4128ipd2 {\n" + |
| 4875 | " public class R {\n" + |
| 4876 | " }\n" + |
| 4877 | " precedence R.b1;\n" + |
| 4878 | "} \n" + |
| 4879 | " \n" |
| 4880 | }, |
| 4881 | "4.8(b)"); |
| 4882 | } |
| 4883 | |
| 4884 | // a team has a precedence declaration - no such role |
| 4885 | // 4.1.28-otjld-invalid-precedence-declaration-3 |
| 4886 | public void test4128_invalidPrecedenceDeclaration3() { |
| 4887 | runNegativeTestMatching( |
| 4888 | new String[] { |
| 4889 | "Team4128ipd3.java", |
| 4890 | "\n" + |
| 4891 | "public team class Team4128ipd3 {\n" + |
| 4892 | " precedence R.b1;\n" + |
| 4893 | "} \n" + |
| 4894 | " \n" |
| 4895 | }, |
| 4896 | "type"); |
| 4897 | } |
| 4898 | |
| 4899 | // a team has two contradicting precedence declarations |
| 4900 | // 4.1.28-otjld-invalid-precedence-declaration-4 |
| 4901 | public void test4128_invalidPrecedenceDeclaration4() { |
| 4902 | runNegativeTestMatching( |
| 4903 | new String[] { |
| 4904 | "Team4128ipd4.java", |
| 4905 | "\n" + |
| 4906 | "public team class Team4128ipd4 {\n" + |
| 4907 | " public class R playedBy T4128ipd4 {\n" + |
| 4908 | " void rm1() { \n" + |
| 4909 | " System.out.print(\"O\"); \n" + |
| 4910 | " }\n" + |
| 4911 | " void rm2() {\n" + |
| 4912 | " System.out.print(\"K\");\n" + |
| 4913 | " }\n" + |
| 4914 | " void rm3() {\n" + |
| 4915 | " System.out.print(\"!\");\n" + |
| 4916 | " }\n" + |
| 4917 | " b1: rm1 <- after bm;\n" + |
| 4918 | " b2: rm2 <- after bm;\n" + |
| 4919 | " b3: rm3 <- after bm;\n" + |
| 4920 | " precedence after b2, b1;\n" + |
| 4921 | " }\n" + |
| 4922 | " precedence after R.b1, R.b2, R.b3;\n" + |
| 4923 | "} \n" + |
| 4924 | " \n", |
| 4925 | "T4128ipd4.java", |
| 4926 | "\n" + |
| 4927 | "public class T4128ipd4 {\n" + |
| 4928 | " void bm() { }\n" + |
| 4929 | "} \n" + |
| 4930 | " \n" |
| 4931 | }, |
| 4932 | "OTJLD 4.8(d)"); |
| 4933 | } |
| 4934 | |
| 4935 | // a role has a precedence declaration, so has its super role |
| 4936 | // 4.1.29-otjld-inheritance-of-precedence-declaration-1 |
| 4937 | public void test4129_inheritanceOfPrecedenceDeclaration1() { |
| 4938 | |
| 4939 | runConformTest( |
| 4940 | new String[] { |
| 4941 | "Team4129iopd1.java", |
| 4942 | "\n" + |
| 4943 | "public team class Team4129iopd1 {\n" + |
| 4944 | " public class R1 playedBy T4129iopd1 {\n" + |
| 4945 | " void rm1() { \n" + |
| 4946 | " System.out.print(\"O\"); \n" + |
| 4947 | " }\n" + |
| 4948 | " void rm2() {\n" + |
| 4949 | " System.out.print(\"K\");\n" + |
| 4950 | " }\n" + |
| 4951 | " b1: rm1 <- after bm;\n" + |
| 4952 | " b2: rm2 <- after bm;\n" + |
| 4953 | " precedence after b2, b1;\n" + |
| 4954 | " }\n" + |
| 4955 | " public class R2 extends R1 {\n" + |
| 4956 | " void rm3() {\n" + |
| 4957 | " System.out.print(\"!\");\n" + |
| 4958 | " }\n" + |
| 4959 | " b3: rm3 <- after bm;\n" + |
| 4960 | " precedence after b3, b2;\n" + |
| 4961 | " }\n" + |
| 4962 | " public static void main(String[] args) {\n" + |
| 4963 | " Team4129iopd1 t = new Team4129iopd1();\n" + |
| 4964 | " t.activate();\n" + |
| 4965 | " T4129iopd1 b = new T4129iopd1();\n" + |
| 4966 | " b.bm();\n" + |
| 4967 | " }\n" + |
| 4968 | "} \n" + |
| 4969 | " \n", |
| 4970 | "T4129iopd1.java", |
| 4971 | "\n" + |
| 4972 | "public class T4129iopd1 {\n" + |
| 4973 | " void bm() { }\n" + |
| 4974 | "} \n" + |
| 4975 | " \n" |
| 4976 | }, |
| 4977 | "OK!"); |
| 4978 | } |
| 4979 | |
| 4980 | // a team has a precedence declaration by role class |
| 4981 | // 4.1.30-otjld-class-based-precedence-declaration-1 |
| 4982 | public void test4130_classBasedPrecedenceDeclaration1() { |
| 4983 | |
| 4984 | runConformTest( |
| 4985 | new String[] { |
| 4986 | "Team4130cbpd1.java", |
| 4987 | "\n" + |
| 4988 | "public team class Team4130cbpd1 {\n" + |
| 4989 | " public class R playedBy T4130cbpd1 {\n" + |
| 4990 | " callin void rm1() {\n" + |
| 4991 | " System.out.print(\"K\");\n" + |
| 4992 | " base.rm1();\n" + |
| 4993 | " System.out.print(\"Y\");\n" + |
| 4994 | " }\n" + |
| 4995 | " rm1 <- replace bm;\n" + |
| 4996 | " }\n" + |
| 4997 | " public class R2 extends R {\n" + |
| 4998 | " callin void rm2() { \n" + |
| 4999 | " System.out.print(\"O\");\n" + |
| 5000 | " base.rm2();\n" + |
| 5001 | " System.out.print(\"!\");\n" + |
| 5002 | " }\n" + |
| 5003 | " rm2 <- replace bm;\n" + |
| 5004 | " }\n" + |
| 5005 | " precedence R2, R;\n" + |
| 5006 | " public static void main(String[] args) {\n" + |
| 5007 | " Team4130cbpd1 t = new Team4130cbpd1();\n" + |
| 5008 | " t.activate();\n" + |
| 5009 | " T4130cbpd1 b = new T4130cbpd1();\n" + |
| 5010 | " b.bm();\n" + |
| 5011 | " }\n" + |
| 5012 | "} \n" + |
| 5013 | " \n", |
| 5014 | "T4130cbpd1.java", |
| 5015 | "\n" + |
| 5016 | "public class T4130cbpd1 {\n" + |
| 5017 | " void bm() { System.out.print(\"A\");}\n" + |
| 5018 | "} \n" + |
| 5019 | " \n" |
| 5020 | }, |
| 5021 | "OKAY!"); |
| 5022 | } |
| 5023 | |
| 5024 | // a role defines a callin binding despite a binding ambiguity |
| 5025 | // 4.1.31-otjld-illegal-lifting-binding-ambiguity-1 |
| 5026 | public void test4131_illegalLiftingBindingAmbiguity1() { |
Stephan Herrmann | b5c7423 | 2011-05-12 19:43:03 +0000 | [diff] [blame] | 5027 | runNegativeTest( |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 5028 | new String[] { |
| 5029 | "Team4131ilba1.java", |
| 5030 | "\n" + |
| 5031 | "public team class Team4131ilba1 {\n" + |
| 5032 | " protected class R0 playedBy T4131ilba1 {\n" + |
| 5033 | " void rm() {};\n" + |
| 5034 | " rm <- after test;\n" + |
| 5035 | " }\n" + |
| 5036 | " protected class R1 extends R0 {}\n" + |
| 5037 | " protected class R2 extends R0 {}\n" + |
| 5038 | "} \n" + |
| 5039 | " \n", |
| 5040 | "T4131ilba1.java", |
| 5041 | "\n" + |
| 5042 | "public class T4131ilba1 {\n" + |
| 5043 | " public void test() {};\n" + |
| 5044 | "} \n" + |
| 5045 | " \n" |
| 5046 | }, |
Stephan Herrmann | b5c7423 | 2011-05-12 19:43:03 +0000 | [diff] [blame] | 5047 | "----------\n" + |
| 5048 | "1. WARNING in Team4131ilba1.java (at line 2)\n" + |
| 5049 | " public team class Team4131ilba1 {\n" + |
| 5050 | " ^^^^^^^^^^^^^\n" + |
| 5051 | "Potential ambiguity in role binding. The base \'T4131ilba1\' is bound to the following roles: Team4131ilba1.R1,Team4131ilba1.R2 (OTJLD 2.3.4(a)).\n" + |
| 5052 | "----------\n" + |
| 5053 | "2. ERROR in Team4131ilba1.java (at line 5)\n" + |
| 5054 | " rm <- after test;\n" + |
| 5055 | " ^^\n" + |
Stephan Herrmann | a00d38b | 2011-05-17 22:24:47 +0000 | [diff] [blame] | 5056 | "Unsafe callin binding, because lifting to role Team4131ilba1.R0 may fail due to a reported binding ambiguity (OTJLD 2.3.5(c)).\n" + |
Stephan Herrmann | b5c7423 | 2011-05-12 19:43:03 +0000 | [diff] [blame] | 5057 | "----------\n" + |
| 5058 | "3. ERROR in Team4131ilba1.java (at line 5)\n" + |
| 5059 | " rm <- after test;\n" + |
| 5060 | " ^^\n" + |
Stephan Herrmann | a00d38b | 2011-05-17 22:24:47 +0000 | [diff] [blame] | 5061 | "Unsafe callin binding, because lifting to role Team4131ilba1.R0 may fail due to a reported binding ambiguity (OTJLD 2.3.5(c)).\n" + |
Stephan Herrmann | b5c7423 | 2011-05-12 19:43:03 +0000 | [diff] [blame] | 5062 | "----------\n"); |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 5063 | } |
| 5064 | |
Stephan Herrmann | d3238f6 | 2011-05-12 21:39:20 +0000 | [diff] [blame] | 5065 | // a definite binding ambiguity is reported (as the need to handle LiftingFailedException) |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 5066 | // 4.1.31-otjld-illegal-lifting-binding-ambiguity-2d |
| 5067 | public void test4131_illegalLiftingBindingAmbiguity2d() { |
| 5068 | runNegativeTestMatching( |
| 5069 | new String[] { |
| 5070 | "Team4131ilba2d.java", |
| 5071 | "\n" + |
| 5072 | "public team class Team4131ilba2d {\n" + |
| 5073 | " protected class R0 playedBy T4131ilba2d {\n" + |
| 5074 | " }\n" + |
| 5075 | " protected class R1 extends R0 {}\n" + |
| 5076 | " protected class R2 extends R0 {}\n" + |
| 5077 | " Team4131ilba2d (T4131ilba2d as R0 o) {}\n" + |
| 5078 | " public static void main(String[] args) {\n" + |
Stephan Herrmann | d3238f6 | 2011-05-12 21:39:20 +0000 | [diff] [blame] | 5079 | " new Team4131ilba2d(new T4131ilba2d());\n" + |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 5080 | " }\n" + |
| 5081 | "} \n" + |
| 5082 | " \n", |
| 5083 | "T4131ilba2d.java", |
| 5084 | "\n" + |
| 5085 | "public class T4131ilba2d {\n" + |
| 5086 | " public void test() {};\n" + |
| 5087 | "} \n" + |
| 5088 | " \n" |
| 5089 | }, |
Stephan Herrmann | d3238f6 | 2011-05-12 21:39:20 +0000 | [diff] [blame] | 5090 | "----------\n" + |
| 5091 | "1. WARNING in Team4131ilba2d.java (at line 2)\n" + |
| 5092 | " public team class Team4131ilba2d {\n" + |
| 5093 | " ^^^^^^^^^^^^^^\n" + |
| 5094 | "Potential ambiguity in role binding. The base \'T4131ilba2d\' is bound to the following roles: Team4131ilba2d.R1,Team4131ilba2d.R2 (OTJLD 2.3.4(a)).\n" + |
| 5095 | "----------\n" + |
| 5096 | "2. ERROR in Team4131ilba2d.java (at line 7)\n" + |
| 5097 | " Team4131ilba2d (T4131ilba2d as R0 o) {}\n" + |
| 5098 | " ^^^^^^^^^^^^^^^^^\n" + |
Stephan Herrmann | 0b2915e | 2011-05-14 12:02:39 +0000 | [diff] [blame] | 5099 | "Unhandled exception type LiftingFailedException, caused by an unsafe lifting request (OTJLD 2.3.5).\n" + |
Stephan Herrmann | d3238f6 | 2011-05-12 21:39:20 +0000 | [diff] [blame] | 5100 | "----------\n"); |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 5101 | } |
| 5102 | |
| 5103 | // a team uses declared lifting despite a binding ambiguity -> runtime exception |
| 5104 | // 4.1.31-otjld-illegal-lifting-binding-ambiguity-2 |
| 5105 | public void test4131_illegalLiftingBindingAmbiguity2() { |
| 5106 | |
| 5107 | runConformTest( |
| 5108 | new String[] { |
| 5109 | "Team4131ilba2.java", |
Stephan Herrmann | 7aa4219 | 2011-05-10 23:29:37 +0000 | [diff] [blame] | 5110 | "import org.objectteams.LiftingFailedException;\n" + |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 5111 | "public team class Team4131ilba2 {\n" + |
| 5112 | " protected class R0 playedBy T4131ilba2_1 {\n" + |
| 5113 | " }\n" + |
| 5114 | " protected class R1 extends R0 playedBy T4131ilba2_2 {}\n" + |
| 5115 | " protected class R2 extends R0 playedBy T4131ilba2_2 {}\n" + |
Stephan Herrmann | 7aa4219 | 2011-05-10 23:29:37 +0000 | [diff] [blame] | 5116 | " Team4131ilba2 (T4131ilba2_1 as R0 o) throws LiftingFailedException {}\n" + |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 5117 | " public static void main(String[] args) {\n" + |
| 5118 | " try {\n" + |
| 5119 | " new Team4131ilba2(new T4131ilba2_2());\n" + |
Stephan Herrmann | 7aa4219 | 2011-05-10 23:29:37 +0000 | [diff] [blame] | 5120 | " } catch (LiftingFailedException e) {\n" + |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 5121 | " System.out.print(\"OK\");\n" + |
| 5122 | " }\n" + |
| 5123 | " }\n" + |
| 5124 | "} \n" + |
| 5125 | " \n", |
| 5126 | "T4131ilba2_1.java", |
| 5127 | "\n" + |
| 5128 | "public class T4131ilba2_1 {\n" + |
| 5129 | " public void test() {};\n" + |
| 5130 | "} \n" + |
| 5131 | " \n", |
| 5132 | "T4131ilba2_2.java", |
| 5133 | "\n" + |
| 5134 | "public class T4131ilba2_2 extends T4131ilba2_1 {\n" + |
| 5135 | "} \n" + |
| 5136 | " \n" |
| 5137 | }, |
| 5138 | "OK"); |
| 5139 | } |
| 5140 | |
| 5141 | // a named callin binding is overridden by an implicit sub role |
| 5142 | // 4.1.32-otjld-overriding-of-callin-binding-1 |
| 5143 | public void test4132_overridingOfCallinBinding1() { |
| 5144 | |
| 5145 | runConformTest( |
| 5146 | new String[] { |
| 5147 | "Team4132oocb1_2.java", |
| 5148 | "\n" + |
| 5149 | "public team class Team4132oocb1_2 extends Team4132oocb1 {\n" + |
| 5150 | " public class R1 {\n" + |
| 5151 | " void rm2() {\n" + |
| 5152 | " System.out.print(\"OK\");\n" + |
| 5153 | " }\n" + |
| 5154 | " b1: rm2 <- before bm;\n" + |
| 5155 | " }\n" + |
| 5156 | " public static void main(String[] args) {\n" + |
| 5157 | " Team4132oocb1_2 t = new Team4132oocb1_2();\n" + |
| 5158 | " t.activate();\n" + |
| 5159 | " T4132oocb1 b = new T4132oocb1();\n" + |
| 5160 | " b.bm();\n" + |
| 5161 | " }\n" + |
| 5162 | "} \n" + |
| 5163 | " \n", |
| 5164 | "T4132oocb1.java", |
| 5165 | "\n" + |
| 5166 | "public class T4132oocb1 {\n" + |
| 5167 | " void bm() {\n" + |
| 5168 | " System.out.print(\"!\");\n" + |
| 5169 | " }\n" + |
| 5170 | "} \n" + |
| 5171 | " \n", |
| 5172 | "Team4132oocb1.java", |
| 5173 | "\n" + |
| 5174 | "public team class Team4132oocb1 {\n" + |
| 5175 | " public class R1 playedBy T4132oocb1 {\n" + |
| 5176 | " void rm1() { \n" + |
| 5177 | " System.out.print(\"NOTOK\"); \n" + |
| 5178 | " }\n" + |
| 5179 | " b1: rm1 <- before bm;\n" + |
| 5180 | " }\n" + |
| 5181 | "} \n" + |
| 5182 | " \n" |
| 5183 | }, |
| 5184 | "OK!"); |
| 5185 | } |
| 5186 | |
| 5187 | // a named callin binding is overridden by an implicit sub role - inherited precedence declaration |
| 5188 | // 4.1.32-otjld-overriding-of-callin-binding-1a |
| 5189 | public void test4132_overridingOfCallinBinding1a() { |
| 5190 | |
| 5191 | runConformTest( |
| 5192 | new String[] { |
| 5193 | "Team4132oocb1a_2.java", |
| 5194 | "\n" + |
| 5195 | "public team class Team4132oocb1a_2 extends Team4132oocb1a {\n" + |
| 5196 | " public class R1 {\n" + |
| 5197 | " void rm3() {\n" + |
| 5198 | " System.out.print(\"O\");\n" + |
| 5199 | " }\n" + |
| 5200 | " b1: rm3 <- before bm;\n" + |
| 5201 | " }\n" + |
| 5202 | " public static void main(String[] args) {\n" + |
| 5203 | " Team4132oocb1a_2 t = new Team4132oocb1a_2();\n" + |
| 5204 | " t.activate();\n" + |
| 5205 | " T4132oocb1a b = new T4132oocb1a();\n" + |
| 5206 | " b.bm();\n" + |
| 5207 | " }\n" + |
| 5208 | "} \n" + |
| 5209 | " \n", |
| 5210 | "T4132oocb1a.java", |
| 5211 | "\n" + |
| 5212 | "public class T4132oocb1a {\n" + |
| 5213 | " void bm() {\n" + |
| 5214 | " System.out.print(\"!\");\n" + |
| 5215 | " }\n" + |
| 5216 | "} \n" + |
| 5217 | " \n", |
| 5218 | "Team4132oocb1a.java", |
| 5219 | "\n" + |
| 5220 | "public team class Team4132oocb1a {\n" + |
| 5221 | " public class R1 playedBy T4132oocb1a {\n" + |
| 5222 | " void rm1() { \n" + |
| 5223 | " System.out.print(\"NOTO\"); \n" + |
| 5224 | " }\n" + |
| 5225 | " void rm2() {\n" + |
| 5226 | " System.out.print(\"K\");\n" + |
| 5227 | " }\n" + |
| 5228 | " b1: rm1 <- before bm;\n" + |
| 5229 | " b2: rm2 <- before bm;\n" + |
| 5230 | " precedence b1, b2;\n" + |
| 5231 | " }\n" + |
| 5232 | "} \n" + |
| 5233 | " \n" |
| 5234 | }, |
| 5235 | "OK!"); |
| 5236 | } |
| 5237 | |
| 5238 | // a named callin binding is overridden by an explicit sub role in the same team |
| 5239 | // 4.1.32-otjld-overriding-of-callin-binding-2 |
| 5240 | public void test4132_overridingOfCallinBinding2() { |
| 5241 | |
| 5242 | runConformTest( |
| 5243 | new String[] { |
| 5244 | "Team4132oocb2.java", |
| 5245 | "\n" + |
| 5246 | "public team class Team4132oocb2 {\n" + |
| 5247 | " public class R1 playedBy T4132oocb2 {\n" + |
| 5248 | " void rm1() { \n" + |
| 5249 | " System.out.print(\"NOTOK\"); \n" + |
| 5250 | " }\n" + |
| 5251 | " b1: rm1 <- before bm;\n" + |
| 5252 | " }\n" + |
| 5253 | " public class R2 extends R1 {\n" + |
| 5254 | " void rm2() {\n" + |
| 5255 | " System.out.print(\"OK\");\n" + |
| 5256 | " }\n" + |
| 5257 | " b1: rm2 <- before bm;\n" + |
| 5258 | " }\n" + |
| 5259 | " public static void main(String[] args) {\n" + |
| 5260 | " Team4132oocb2 t = new Team4132oocb2();\n" + |
| 5261 | " t.activate();\n" + |
| 5262 | " T4132oocb2 b = new T4132oocb2();\n" + |
| 5263 | " b.bm();\n" + |
| 5264 | " }\n" + |
| 5265 | "} \n" + |
| 5266 | " \n", |
| 5267 | "T4132oocb2.java", |
| 5268 | "\n" + |
| 5269 | "public class T4132oocb2 {\n" + |
| 5270 | " void bm() { \n" + |
| 5271 | " System.out.print(\"!\");\n" + |
| 5272 | " }\n" + |
| 5273 | "} \n" + |
| 5274 | " \n" |
| 5275 | }, |
| 5276 | "OK!"); |
| 5277 | } |
| 5278 | |
| 5279 | // a named callin binding is overridden by an explicit sub role in the same team - inherited precedence declaration |
| 5280 | // 4.1.32-otjld-overriding-of-callin-binding-2a |
| 5281 | public void test4132_overridingOfCallinBinding2a() { |
| 5282 | |
| 5283 | runConformTest( |
| 5284 | new String[] { |
| 5285 | "Team4132oocb2a.java", |
| 5286 | "\n" + |
| 5287 | "public team class Team4132oocb2a {\n" + |
| 5288 | " public class R1 playedBy T4132oocb2a {\n" + |
| 5289 | " void rm1() { \n" + |
| 5290 | " System.out.print(\"NOTO\"); \n" + |
| 5291 | " }\n" + |
| 5292 | " void rm2() {\n" + |
| 5293 | " System.out.print(\"K\");\n" + |
| 5294 | " }\n" + |
| 5295 | " b1: rm1 <- before bm;\n" + |
| 5296 | " b2: rm2 <- before bm;\n" + |
| 5297 | " precedence b1, b2;\n" + |
| 5298 | " }\n" + |
| 5299 | " public class R2 extends R1 {\n" + |
| 5300 | " void rm3() {\n" + |
| 5301 | " System.out.print(\"O\");\n" + |
| 5302 | " }\n" + |
| 5303 | " b1: rm3 <- before bm;\n" + |
| 5304 | " }\n" + |
| 5305 | " public static void main(String[] args) {\n" + |
| 5306 | " Team4132oocb2a t = new Team4132oocb2a();\n" + |
| 5307 | " t.activate();\n" + |
| 5308 | " T4132oocb2a b = new T4132oocb2a();\n" + |
| 5309 | " b.bm();\n" + |
| 5310 | " }\n" + |
| 5311 | "} \n" + |
| 5312 | " \n", |
| 5313 | "T4132oocb2a.java", |
| 5314 | "\n" + |
| 5315 | "public class T4132oocb2a {\n" + |
| 5316 | " void bm() {\n" + |
| 5317 | " System.out.print(\"!\");\n" + |
| 5318 | " }\n" + |
| 5319 | "} \n" + |
| 5320 | " \n" |
| 5321 | }, |
| 5322 | "OK!"); |
| 5323 | } |
| 5324 | |
| 5325 | // a named callin binding is overridden by an explicit sub role in a sub team |
| 5326 | // 4.1.32-otjld-overriding-of-callin-binding-3 |
| 5327 | public void test4132_overridingOfCallinBinding3() { |
| 5328 | |
| 5329 | runConformTest( |
| 5330 | new String[] { |
| 5331 | "Team4132oocb3_2.java", |
| 5332 | "\n" + |
| 5333 | "public team class Team4132oocb3_2 extends Team4132oocb3 {\n" + |
| 5334 | " public class R2 extends R1 {\n" + |
| 5335 | " void rm2() {\n" + |
| 5336 | " System.out.print(\"OK\");\n" + |
| 5337 | " }\n" + |
| 5338 | " b1: rm2 <- before bm;\n" + |
| 5339 | " }\n" + |
| 5340 | " public static void main(String[] args) {\n" + |
| 5341 | " Team4132oocb3_2 t = new Team4132oocb3_2();\n" + |
| 5342 | " t.activate();\n" + |
| 5343 | " T4132oocb3 b = new T4132oocb3();\n" + |
| 5344 | " b.bm();\n" + |
| 5345 | " }\n" + |
| 5346 | "} \n" + |
| 5347 | " \n", |
| 5348 | "T4132oocb3.java", |
| 5349 | "\n" + |
| 5350 | "public class T4132oocb3 {\n" + |
| 5351 | " void bm() { \n" + |
| 5352 | " System.out.print(\"!\");\n" + |
| 5353 | " }\n" + |
| 5354 | "} \n" + |
| 5355 | " \n", |
| 5356 | "Team4132oocb3.java", |
| 5357 | "\n" + |
| 5358 | "public team class Team4132oocb3 {\n" + |
| 5359 | " public class R1 playedBy T4132oocb3 {\n" + |
| 5360 | " void rm1() { \n" + |
| 5361 | " System.out.print(\"NOTOK\"); \n" + |
| 5362 | " }\n" + |
| 5363 | " b1: rm1 <- before bm;\n" + |
| 5364 | " }\n" + |
| 5365 | "} \n" + |
| 5366 | " \n" |
| 5367 | }, |
| 5368 | "OK!"); |
| 5369 | } |
| 5370 | |
| 5371 | // a named callin binding is overridden by an explicit sub role in a sub team - inherited precedence declaration |
| 5372 | // 4.1.32-otjld-overriding-of-callin-binding-3a |
| 5373 | public void test4132_overridingOfCallinBinding3a() { |
| 5374 | |
| 5375 | runConformTest( |
| 5376 | new String[] { |
| 5377 | "Team4132oocb3a_2.java", |
| 5378 | "\n" + |
| 5379 | "public team class Team4132oocb3a_2 extends Team4132oocb3a {\n" + |
| 5380 | " public class R2 extends R1 {\n" + |
| 5381 | " void rm3() {\n" + |
| 5382 | " System.out.print(\"O\");\n" + |
| 5383 | " }\n" + |
| 5384 | " b1: rm3 <- before bm;\n" + |
| 5385 | " }\n" + |
| 5386 | " public static void main(String[] args) {\n" + |
| 5387 | " Team4132oocb3a_2 t = new Team4132oocb3a_2();\n" + |
| 5388 | " t.activate();\n" + |
| 5389 | " T4132oocb3a b = new T4132oocb3a();\n" + |
| 5390 | " b.bm();\n" + |
| 5391 | " }\n" + |
| 5392 | "} \n" + |
| 5393 | " \n", |
| 5394 | "T4132oocb3a.java", |
| 5395 | "\n" + |
| 5396 | "public class T4132oocb3a {\n" + |
| 5397 | " void bm() { \n" + |
| 5398 | " System.out.print(\"!\");\n" + |
| 5399 | " }\n" + |
| 5400 | "} \n" + |
| 5401 | " \n", |
| 5402 | "Team4132oocb3a.java", |
| 5403 | "\n" + |
| 5404 | "public team class Team4132oocb3a {\n" + |
| 5405 | " public class R1 playedBy T4132oocb3a {\n" + |
| 5406 | " void rm1() { \n" + |
| 5407 | " System.out.print(\"NOTO\"); \n" + |
| 5408 | " }\n" + |
| 5409 | " void rm2() {\n" + |
| 5410 | " System.out.print(\"K\");\n" + |
| 5411 | " }\n" + |
| 5412 | " b1: rm1 <- before bm;\n" + |
| 5413 | " b2: rm2 <- before bm;\n" + |
| 5414 | " precedence b1, b2;\n" + |
| 5415 | " }\n" + |
| 5416 | "} \n" + |
| 5417 | " \n" |
| 5418 | }, |
| 5419 | "OK!"); |
| 5420 | } |
| 5421 | |
| 5422 | // a named callin binding is overridden by an explicit subsub role in a sub team |
| 5423 | // 4.1.32-otjld-overriding-of-callin-binding-4 |
| 5424 | public void test4132_overridingOfCallinBinding4() { |
| 5425 | |
| 5426 | runConformTest( |
| 5427 | new String[] { |
| 5428 | "Team4132oocb4_2.java", |
| 5429 | "\n" + |
| 5430 | "public team class Team4132oocb4_2 extends Team4132oocb4 {\n" + |
| 5431 | " public class R2 extends R1 { }\n" + |
| 5432 | " public class R3 extends R2 {\n" + |
| 5433 | " void rm2() {\n" + |
| 5434 | " System.out.print(\"OK\");\n" + |
| 5435 | " }\n" + |
| 5436 | " b1: rm2 <- before bm;\n" + |
| 5437 | " }\n" + |
| 5438 | " public static void main(String[] args) {\n" + |
| 5439 | " Team4132oocb4_2 t = new Team4132oocb4_2();\n" + |
| 5440 | " t.activate();\n" + |
| 5441 | " T4132oocb4 b = new T4132oocb4();\n" + |
| 5442 | " b.bm();\n" + |
| 5443 | " }\n" + |
| 5444 | "} \n" + |
| 5445 | " \n", |
| 5446 | "T4132oocb4.java", |
| 5447 | "\n" + |
| 5448 | "public class T4132oocb4 {\n" + |
| 5449 | " void bm() { \n" + |
| 5450 | " System.out.print(\"!\");\n" + |
| 5451 | " }\n" + |
| 5452 | "} \n" + |
| 5453 | " \n", |
| 5454 | "Team4132oocb4.java", |
| 5455 | "\n" + |
| 5456 | "public team class Team4132oocb4 {\n" + |
| 5457 | " public class R1 playedBy T4132oocb4 {\n" + |
| 5458 | " void rm1() { \n" + |
| 5459 | " System.out.print(\"NOTOK\"); \n" + |
| 5460 | " }\n" + |
| 5461 | " b1: rm1 <- before bm;\n" + |
| 5462 | " }\n" + |
| 5463 | "} \n" + |
| 5464 | " \n" |
| 5465 | }, |
| 5466 | "OK!"); |
| 5467 | } |
| 5468 | |
| 5469 | // a named callin binding is overridden by an explicit subsub role in a sub team - inherited precedence declaration |
| 5470 | // 4.1.32-otjld-overriding-of-callin-binding-4a |
| 5471 | public void test4132_overridingOfCallinBinding4a() { |
| 5472 | |
| 5473 | runConformTest( |
| 5474 | new String[] { |
| 5475 | "Team4132oocb4a_2.java", |
| 5476 | "\n" + |
| 5477 | "public team class Team4132oocb4a_2 extends Team4132oocb4a {\n" + |
| 5478 | " public class R2 extends R1 { }\n" + |
| 5479 | " public class R3 extends R2 {\n" + |
| 5480 | " void rm3() {\n" + |
| 5481 | " System.out.print(\"O\");\n" + |
| 5482 | " }\n" + |
| 5483 | " b1: rm3 <- before bm;\n" + |
| 5484 | " }\n" + |
| 5485 | " public static void main(String[] args) {\n" + |
| 5486 | " Team4132oocb4a_2 t = new Team4132oocb4a_2();\n" + |
| 5487 | " t.activate();\n" + |
| 5488 | " T4132oocb4a b = new T4132oocb4a();\n" + |
| 5489 | " b.bm();\n" + |
| 5490 | " }\n" + |
| 5491 | "} \n" + |
| 5492 | " \n", |
| 5493 | "T4132oocb4a.java", |
| 5494 | "\n" + |
| 5495 | "public class T4132oocb4a {\n" + |
| 5496 | " void bm() { \n" + |
| 5497 | " System.out.print(\"!\");\n" + |
| 5498 | " }\n" + |
| 5499 | "} \n" + |
| 5500 | " \n", |
| 5501 | "Team4132oocb4a.java", |
| 5502 | "\n" + |
| 5503 | "public team class Team4132oocb4a {\n" + |
| 5504 | " public class R1 playedBy T4132oocb4a {\n" + |
| 5505 | " void rm1() { \n" + |
| 5506 | " System.out.print(\"NOTO\"); \n" + |
| 5507 | " }\n" + |
| 5508 | " void rm2() {\n" + |
| 5509 | " System.out.print(\"K\");\n" + |
| 5510 | " }\n" + |
| 5511 | " b1: rm1 <- before bm;\n" + |
| 5512 | " b2: rm2 <- before bm;\n" + |
| 5513 | " precedence b1, b2;\n" + |
| 5514 | " }\n" + |
| 5515 | "} \n" + |
| 5516 | " \n" |
| 5517 | }, |
| 5518 | "OK!"); |
| 5519 | } |
| 5520 | |
| 5521 | // a named callin binding is overridden by an explicit subsub role in the same team |
| 5522 | // 4.1.32-otjld-overriding-of-callin-binding-5 |
| 5523 | public void test4132_overridingOfCallinBinding5() { |
| 5524 | |
| 5525 | runConformTest( |
| 5526 | new String[] { |
| 5527 | "Team4132oocb5.java", |
| 5528 | "\n" + |
| 5529 | "public team class Team4132oocb5 {\n" + |
| 5530 | " public class R1 playedBy T4132oocb5 {\n" + |
| 5531 | " void rm1() { \n" + |
| 5532 | " System.out.print(\"NOTOK\"); \n" + |
| 5533 | " }\n" + |
| 5534 | " b1: rm1 <- before bm;\n" + |
| 5535 | " }\n" + |
| 5536 | " public class R2 extends R1 {}\n" + |
| 5537 | " public class R3 extends R2 {\n" + |
| 5538 | " void rm2() {\n" + |
| 5539 | " System.out.print(\"OK\");\n" + |
| 5540 | " }\n" + |
| 5541 | " b1: rm2 <- before bm;\n" + |
| 5542 | " }\n" + |
| 5543 | " public static void main(String[] args) {\n" + |
| 5544 | " Team4132oocb5 t = new Team4132oocb5();\n" + |
| 5545 | " t.activate();\n" + |
| 5546 | " T4132oocb5 b = new T4132oocb5();\n" + |
| 5547 | " b.bm();\n" + |
| 5548 | " }\n" + |
| 5549 | "} \n" + |
| 5550 | " \n", |
| 5551 | "T4132oocb5.java", |
| 5552 | "\n" + |
| 5553 | "public class T4132oocb5 {\n" + |
| 5554 | " void bm() { \n" + |
| 5555 | " System.out.print(\"!\");\n" + |
| 5556 | " }\n" + |
| 5557 | "} \n" + |
| 5558 | " \n" |
| 5559 | }, |
| 5560 | "OK!"); |
| 5561 | } |
| 5562 | |
| 5563 | // a callin binding overrides another, but additionally there is a precedence declaration between them |
| 5564 | // 4.1.32-otjld-overriding-of-callin-binding-6 |
| 5565 | public void test4132_overridingOfCallinBinding6() { |
| 5566 | |
| 5567 | runConformTest( |
| 5568 | new String[] { |
| 5569 | "Team4132oocb6.java", |
| 5570 | "\n" + |
| 5571 | "public team class Team4132oocb6 {\n" + |
| 5572 | " precedence R2, R1;\n" + |
| 5573 | "\n" + |
| 5574 | " public class R1 playedBy T4132oocb6 {\n" + |
| 5575 | " void rm1() { \n" + |
| 5576 | " System.out.print(\"NOT\"); \n" + |
| 5577 | " }\n" + |
| 5578 | " b1: rm1 <- before bm;\n" + |
| 5579 | " }\n" + |
| 5580 | " public class R2 extends R1 {\n" + |
| 5581 | " void rm2() {\n" + |
| 5582 | " System.out.print(\"OK\");\n" + |
| 5583 | " }\n" + |
| 5584 | " b1: rm2 <- before bm;\n" + |
| 5585 | " }\n" + |
| 5586 | " public static void main(String[] args) {\n" + |
| 5587 | " Team4132oocb6 t = new Team4132oocb6();\n" + |
| 5588 | " t.activate();\n" + |
| 5589 | " T4132oocb6 b = new T4132oocb6();\n" + |
| 5590 | " b.bm();\n" + |
| 5591 | " }\n" + |
| 5592 | "} \n" + |
| 5593 | " \n", |
| 5594 | "T4132oocb6.java", |
| 5595 | "\n" + |
| 5596 | "public class T4132oocb6 {\n" + |
| 5597 | " void bm() { \n" + |
| 5598 | " System.out.print(\"!\");\n" + |
| 5599 | " }\n" + |
| 5600 | "} \n" + |
| 5601 | " \n" |
| 5602 | }, |
| 5603 | "OK!"); |
| 5604 | } |
| 5605 | |
| 5606 | // a callin binding overrides another, but additionally there is a precedence declaration between them - different order |
| 5607 | // 4.1.32-otjld-overriding-of-callin-binding-6a |
| 5608 | public void test4132_overridingOfCallinBinding6a() { |
| 5609 | |
| 5610 | runConformTest( |
| 5611 | new String[] { |
| 5612 | "Team4132oocb6a.java", |
| 5613 | "\n" + |
| 5614 | "public team class Team4132oocb6a {\n" + |
| 5615 | " precedence R1, R2;\n" + |
| 5616 | "\n" + |
| 5617 | " public class R1 playedBy T4132oocb6a {\n" + |
| 5618 | " void rm1() { \n" + |
| 5619 | " System.out.print(\"NOT\"); \n" + |
| 5620 | " }\n" + |
| 5621 | " b1: rm1 <- before bm;\n" + |
| 5622 | " }\n" + |
| 5623 | " public class R2 extends R1 {\n" + |
| 5624 | " void rm2() {\n" + |
| 5625 | " System.out.print(\"OK\");\n" + |
| 5626 | " }\n" + |
| 5627 | " b1: rm2 <- before bm;\n" + |
| 5628 | " }\n" + |
| 5629 | " public static void main(String[] args) {\n" + |
| 5630 | " Team4132oocb6a t = new Team4132oocb6a();\n" + |
| 5631 | " t.activate();\n" + |
| 5632 | " T4132oocb6a b = new T4132oocb6a();\n" + |
| 5633 | " b.bm();\n" + |
| 5634 | " }\n" + |
| 5635 | "} \n" + |
| 5636 | " \n", |
| 5637 | "T4132oocb6a.java", |
| 5638 | "\n" + |
| 5639 | "public class T4132oocb6a {\n" + |
| 5640 | " void bm() { \n" + |
| 5641 | " System.out.print(\"!\");\n" + |
| 5642 | " }\n" + |
| 5643 | "} \n" + |
| 5644 | " \n" |
| 5645 | }, |
| 5646 | "OK!"); |
| 5647 | } |
| 5648 | |
| 5649 | // a callin binding overrides another, but additionally there is a precedence declaration between them |
| 5650 | // 4.1.32-otjld-overriding-of-callin-binding-7 |
| 5651 | public void test4132_overridingOfCallinBinding7() { |
| 5652 | |
| 5653 | runConformTest( |
| 5654 | new String[] { |
| 5655 | "Team4132oocb7.java", |
| 5656 | "\n" + |
| 5657 | "public team class Team4132oocb7 {\n" + |
| 5658 | " precedence R2, R1;\n" + |
| 5659 | "\n" + |
| 5660 | " public class R1 playedBy T4132oocb7 {\n" + |
| 5661 | " void rm1() { \n" + |
| 5662 | " System.out.print(\"NOT\"); \n" + |
| 5663 | " }\n" + |
| 5664 | " void rm3() {\n" + |
| 5665 | " System.out.print(\"K\");\n" + |
| 5666 | " }\n" + |
| 5667 | " b1: rm1 <- before bm;\n" + |
| 5668 | " b2: rm3 <- before bm;\n" + |
| 5669 | " }\n" + |
| 5670 | " public class R2 extends R1 {\n" + |
| 5671 | " void rm2() {\n" + |
| 5672 | " System.out.print(\"O\");\n" + |
| 5673 | " }\n" + |
| 5674 | " b1: rm2 <- before bm;\n" + |
| 5675 | " }\n" + |
| 5676 | " public static void main(String[] args) {\n" + |
| 5677 | " Team4132oocb7 t = new Team4132oocb7();\n" + |
| 5678 | " t.activate();\n" + |
| 5679 | " T4132oocb7 b = new T4132oocb7();\n" + |
| 5680 | " b.bm();\n" + |
| 5681 | " }\n" + |
| 5682 | "} \n" + |
| 5683 | " \n", |
| 5684 | "T4132oocb7.java", |
| 5685 | "\n" + |
| 5686 | "public class T4132oocb7 {\n" + |
| 5687 | " void bm() { \n" + |
| 5688 | " System.out.print(\"!\");\n" + |
| 5689 | " }\n" + |
| 5690 | "} \n" + |
| 5691 | " \n" |
| 5692 | }, |
| 5693 | "OK!"); |
| 5694 | } |
| 5695 | |
| 5696 | // a precedence list mentions to callin bindings overriding each other |
| 5697 | // 4.1.32-otjld-overriding-of-callin-binding-8 |
| 5698 | public void test4132_overridingOfCallinBinding8() { |
| 5699 | runNegativeTestMatching( |
| 5700 | new String[] { |
| 5701 | "Team4132oocb8.java", |
| 5702 | "\n" + |
| 5703 | "public team class Team4132oocb8 {\n" + |
| 5704 | " protected class R1 playedBy T4132oocb8 {\n" + |
| 5705 | " void rm() {}\n" + |
| 5706 | " b1: rm <- after bm;\n" + |
| 5707 | " }\n" + |
| 5708 | " protected class R2 extends R1 {\n" + |
| 5709 | " void rm2() {}\n" + |
| 5710 | " b1: rm2 <- after bm;\n" + |
| 5711 | " }\n" + |
| 5712 | " precedence R2.b1, R1.b1;\n" + |
| 5713 | "}\n" + |
| 5714 | " \n", |
| 5715 | "T4132oocb8.java", |
| 5716 | "\n" + |
| 5717 | "public class T4132oocb8 {\n" + |
| 5718 | " void bm() {}\n" + |
| 5719 | "}\n" + |
| 5720 | " \n" |
| 5721 | }, |
| 5722 | "4.8(e)"); |
| 5723 | } |
| 5724 | |
| 5725 | // a callin label is used twice within the same role class |
| 5726 | // 4.1.32-otjld-overriding-of-callin-binding-9 |
| 5727 | public void test4132_overridingOfCallinBinding9() { |
| 5728 | runNegativeTestMatching( |
| 5729 | new String[] { |
| 5730 | "Team4132oocb9.java", |
| 5731 | "\n" + |
| 5732 | "public team class Team4132oocb9 {\n" + |
| 5733 | " protected class R playedBy T4132oocb9 {\n" + |
| 5734 | " void test1() { }\n" + |
| 5735 | " void test2() { }\n" + |
| 5736 | " label: test1 <- after bm;\n" + |
| 5737 | " label: test2 <- after bm;\n" + |
| 5738 | " }\n" + |
| 5739 | " public static void main(String[] args) {\n" + |
| 5740 | " Team4132oocb9 t = new Team4132oocb9();\n" + |
| 5741 | " t.activate();\n" + |
| 5742 | " new T4132oocb9().bm();\n" + |
| 5743 | " }\n" + |
| 5744 | "}\n" + |
| 5745 | " \n", |
| 5746 | "T4132oocb9.java", |
| 5747 | "\n" + |
| 5748 | "public class T4132oocb9 {\n" + |
| 5749 | " void bm() {}\n" + |
| 5750 | "}\n" + |
| 5751 | " \n" |
| 5752 | }, |
| 5753 | "4.1(e)"); |
| 5754 | } |
| 5755 | |
| 5756 | // a callin method is marked private |
| 5757 | // 4.1.33-otjld-callin-to-private-1 |
| 5758 | public void test4133_callinToPrivate1() { |
| 5759 | runNegativeTestMatching( |
| 5760 | new String[] { |
| 5761 | "Team4133ctp1.java", |
| 5762 | "\n" + |
| 5763 | "public team class Team4133ctp1 {\n" + |
| 5764 | " protected class R playedBy T4133ctp1 {\n" + |
| 5765 | " private callin void rm() {\n" + |
| 5766 | " System.out.print(\"O\");\n" + |
| 5767 | " base.rm();\n" + |
| 5768 | " }\n" + |
| 5769 | " }\n" + |
| 5770 | "}\n" + |
| 5771 | " \n", |
| 5772 | "T4133ctp1.java", |
| 5773 | "\n" + |
| 5774 | "public team class T4133ctp1 {\n" + |
| 5775 | " void bm() {\n" + |
| 5776 | " System.out.print(\"K\");\n" + |
| 5777 | " }\n" + |
| 5778 | "}\n" + |
| 5779 | " \n" |
| 5780 | }, |
| 5781 | "4.2(d)"); |
| 5782 | } |
| 5783 | |
| 5784 | // a private role method is before bound |
| 5785 | // 4.1.33-otjld-callin-to-private-2 |
| 5786 | public void test4133_callinToPrivate2() { |
| 5787 | //FIXME HACK: |
| 5788 | //this.verifier = getTestVerifier(true); |
| 5789 | |
| 5790 | runConformTest( |
| 5791 | new String[] { |
| 5792 | "Team4133ctp2.java", |
| 5793 | "\n" + |
| 5794 | "public team class Team4133ctp2 {\n" + |
| 5795 | " protected class R playedBy T4133ctp2 {\n" + |
| 5796 | " private void rm() {\n" + |
| 5797 | " System.out.print(\"O\");\n" + |
| 5798 | " }\n" + |
| 5799 | " rm <- before bm;\n" + |
| 5800 | " }\n" + |
| 5801 | " public static void main(String[] args) {\n" + |
| 5802 | " new Team4133ctp2().activate();\n" + |
| 5803 | " new T4133ctp2().bm();\n" + |
| 5804 | " }\n" + |
| 5805 | "}\n" + |
| 5806 | " \n", |
| 5807 | "T4133ctp2.java", |
| 5808 | "\n" + |
| 5809 | "public team class T4133ctp2 {\n" + |
| 5810 | " void bm() {\n" + |
| 5811 | " System.out.print(\"K\");\n" + |
| 5812 | " }\n" + |
| 5813 | "}\n" + |
| 5814 | " \n" |
| 5815 | }, |
| 5816 | "OK"); |
| 5817 | } |
| 5818 | |
| 5819 | // a private static role method is before bound |
| 5820 | // 4.1.33-otjld-callin-to-private-2s |
| 5821 | public void test4133_callinToPrivate2s() { |
| 5822 | |
| 5823 | runConformTest( |
| 5824 | new String[] { |
| 5825 | "Team4133ctp2s.java", |
| 5826 | "\n" + |
| 5827 | "public team class Team4133ctp2s {\n" + |
| 5828 | " protected class R playedBy T4133ctp2s {\n" + |
| 5829 | " private static void rm(Object o) {\n" + |
| 5830 | " System.out.print(o);\n" + |
| 5831 | " }\n" + |
| 5832 | " void rm(Object o) <- before void bm()\n" + |
| 5833 | " with { o <- \"O\" }\n" + |
| 5834 | " }\n" + |
| 5835 | " public static void main(String[] args) {\n" + |
| 5836 | " new Team4133ctp2s().activate();\n" + |
| 5837 | " new T4133ctp2s().bm();\n" + |
| 5838 | " }\n" + |
| 5839 | "}\n" + |
| 5840 | " \n", |
| 5841 | "T4133ctp2s.java", |
| 5842 | "\n" + |
| 5843 | "public team class T4133ctp2s {\n" + |
| 5844 | " void bm() {\n" + |
| 5845 | " System.out.print(\"K\");\n" + |
| 5846 | " }\n" + |
| 5847 | "}\n" + |
| 5848 | " \n" |
| 5849 | }, |
| 5850 | "OK"); |
| 5851 | } |
| 5852 | |
| 5853 | // a callin method has several modifiers |
| 5854 | // 4.1.33-otjld-callin-to-private-3 |
| 5855 | public void test4133_callinToPrivate3() { |
| 5856 | runNegativeTestMatching( |
| 5857 | new String[] { |
| 5858 | "Team4133ctp3.java", |
| 5859 | "\n" + |
| 5860 | "public team class Team4133ctp3 {\n" + |
| 5861 | " protected class R playedBy T4133ctp3 {\n" + |
| 5862 | " synchronized protected callin void rm() {\n" + |
| 5863 | " System.out.print(\"O\");\n" + |
| 5864 | " base.rm();\n" + |
| 5865 | " }\n" + |
| 5866 | " }\n" + |
| 5867 | "}\n" + |
| 5868 | " \n", |
| 5869 | "T4133ctp3.java", |
| 5870 | "\n" + |
| 5871 | "public team class T4133ctp3 {\n" + |
| 5872 | " void bm() {\n" + |
| 5873 | " System.out.print(\"K\");\n" + |
| 5874 | " }\n" + |
| 5875 | "}\n" + |
| 5876 | " \n" |
| 5877 | }, |
| 5878 | "4.2(d)"); |
| 5879 | } |
| 5880 | |
| 5881 | // a try-finally block (->'ret' instruction) is used in a callin method |
| 5882 | // 4.1.34-otjld-local-variables-in-callin-methods-1 |
| 5883 | public void test4134_localVariablesInCallinMethods1() { |
| 5884 | |
| 5885 | runConformTest( |
| 5886 | new String[] { |
| 5887 | "Team4134lvicm1.java", |
| 5888 | "\n" + |
| 5889 | "public team class Team4134lvicm1 {\n" + |
| 5890 | " protected class R playedBy T4134lvicm1 {\n" + |
| 5891 | " callin String rm() {\n" + |
| 5892 | " String b = base.rm();\n" + |
| 5893 | " try {\n" + |
| 5894 | " b = b + \"\";\n" + |
| 5895 | " } finally {\n" + |
| 5896 | " b = \"O\"+b;\n" + |
| 5897 | " } \n" + |
| 5898 | " return b;\n" + |
| 5899 | " }\n" + |
| 5900 | " rm <- replace bm;\n" + |
| 5901 | " }\n" + |
| 5902 | " public static void main(String[] args) {\n" + |
| 5903 | " T4134lvicm1 b = new T4134lvicm1();\n" + |
| 5904 | " Team4134lvicm1 t = new Team4134lvicm1();\n" + |
| 5905 | " t.activate();\n" + |
| 5906 | " System.out.print(b.bm());\n" + |
| 5907 | " }\n" + |
| 5908 | "}\n" + |
| 5909 | " \n", |
| 5910 | "T4134lvicm1.java", |
| 5911 | "\n" + |
| 5912 | "public team class T4134lvicm1 {\n" + |
| 5913 | " String bm() {\n" + |
| 5914 | " return \"K\";\n" + |
| 5915 | " }\n" + |
| 5916 | "}\n" + |
| 5917 | " \n" |
| 5918 | }, |
| 5919 | "OK"); |
| 5920 | } |
| 5921 | |
| 5922 | // a local variable in a callin method is incremented |
| 5923 | // 4.1.34-otjld-local-variables-in-callin-methods-2 |
| 5924 | public void test4134_localVariablesInCallinMethods2() { |
| 5925 | |
| 5926 | runConformTest( |
| 5927 | new String[] { |
| 5928 | "Team4134lvicm2.java", |
| 5929 | "\n" + |
| 5930 | "public team class Team4134lvicm2 {\n" + |
| 5931 | " protected class R playedBy T4134lvicm2 {\n" + |
| 5932 | " callin void rm(int i) {\n" + |
| 5933 | " int my_i = i;\n" + |
| 5934 | " base.rm(my_i);\n" + |
| 5935 | " for (int my_i2=i+1; my_i2<4; my_i2++) {\n" + |
| 5936 | " System.out.print(my_i2);\n" + |
| 5937 | " }\n" + |
| 5938 | " }\n" + |
| 5939 | " rm <- replace bm;\n" + |
| 5940 | " }\n" + |
| 5941 | " public static void main(String[] args) {\n" + |
| 5942 | " T4134lvicm2 b = new T4134lvicm2();\n" + |
| 5943 | " Team4134lvicm2 t = new Team4134lvicm2();\n" + |
| 5944 | " t.activate();\n" + |
| 5945 | " b.bm(1);\n" + |
| 5946 | " }\n" + |
| 5947 | "}\n" + |
| 5948 | " \n", |
| 5949 | "T4134lvicm2.java", |
| 5950 | "\n" + |
| 5951 | "public team class T4134lvicm2 {\n" + |
| 5952 | " void bm(int i) {\n" + |
| 5953 | " System.out.print(i);\n" + |
| 5954 | " }\n" + |
| 5955 | "}\n" + |
| 5956 | " \n" |
| 5957 | }, |
| 5958 | "123"); |
| 5959 | } |
| 5960 | |
| 5961 | // an exception handler is used in a callin method |
| 5962 | // 4.1.34-otjld-local-variables-in-callin-methods-3 |
| 5963 | public void test4134_localVariablesInCallinMethods3() { |
| 5964 | |
| 5965 | runConformTest( |
| 5966 | new String[] { |
| 5967 | "T4134lvicmMain3.java", |
| 5968 | "\n" + |
| 5969 | "public class T4134lvicmMain3 {\n" + |
| 5970 | " public static void main(String[] args) {\n" + |
| 5971 | " T4134lvicm3 b = new T4134lvicm3();\n" + |
| 5972 | " Team4134lvicm3 t = new Team4134lvicm3();\n" + |
| 5973 | " t.activate();\n" + |
| 5974 | " b.bm(2);\n" + |
| 5975 | " }\n" + |
| 5976 | "}\n" + |
| 5977 | " \n", |
| 5978 | "T4134lvicm3.java", |
| 5979 | "\n" + |
| 5980 | "public team class T4134lvicm3 {\n" + |
| 5981 | " void bm(int i) {\n" + |
| 5982 | " System.out.print(10/i);\n" + |
| 5983 | " }\n" + |
| 5984 | "}\n" + |
| 5985 | " \n", |
| 5986 | "Team4134lvicm3.java", |
| 5987 | "\n" + |
| 5988 | "public team class Team4134lvicm3 {\n" + |
| 5989 | " protected class R playedBy T4134lvicm3 {\n" + |
| 5990 | " callin void rm(int i) {\n" + |
| 5991 | " try {\n" + |
| 5992 | " base.rm(i-2);\n" + |
| 5993 | " } catch(Exception e) {\n" + |
| 5994 | " base.rm(i);\n" + |
| 5995 | " }\n" + |
| 5996 | " }\n" + |
| 5997 | " rm <- replace bm;\n" + |
| 5998 | " }\n" + |
| 5999 | "\n" + |
| 6000 | "}\n" + |
| 6001 | " \n" |
| 6002 | }, |
| 6003 | "5"); |
| 6004 | // FIXME expect this warning |
| 6005 | } |
| 6006 | |
| 6007 | // basic type arguments are unused in the role method signaturen |
| 6008 | // 4.1.35-otjld-basic-type-unused-args-1 |
| 6009 | public void test4135_basicTypeUnusedArgs1() { |
| 6010 | |
| 6011 | runConformTest( |
| 6012 | new String[] { |
| 6013 | "Team4135btua1.java", |
| 6014 | "\n" + |
| 6015 | "public team class Team4135btua1 {\n" + |
| 6016 | " protected class R playedBy T4135btua1 {\n" + |
| 6017 | " callin void rm() {\n" + |
| 6018 | " base.rm();\n" + |
| 6019 | " System.out.print(\"K\");\n" + |
| 6020 | " }\n" + |
| 6021 | " rm <- replace bm;\n" + |
| 6022 | " }\n" + |
| 6023 | " public static void main(String[] args) {\n" + |
| 6024 | " T4135btua1 b = new T4135btua1();\n" + |
| 6025 | " Team4135btua1 t = new Team4135btua1();\n" + |
| 6026 | " t.activate();\n" + |
| 6027 | " b.bm(true, 1, (float)2.0, (double)3.0, (short)4, (byte)5, 'c', (long)7);\n" + |
| 6028 | " }\n" + |
| 6029 | "}\n" + |
| 6030 | " \n", |
| 6031 | "T4135btua1.java", |
| 6032 | "\n" + |
| 6033 | "public team class T4135btua1 {\n" + |
| 6034 | " void bm(boolean b, int i, float f, double d, short s, byte by, char c, long l) {\n" + |
| 6035 | " System.out.print(\"O\");\n" + |
| 6036 | " }\n" + |
| 6037 | "}\n" + |
| 6038 | " \n" |
| 6039 | }, |
| 6040 | "OK"); |
| 6041 | } |
| 6042 | |
| 6043 | // a callin method calls its explicit super method |
| 6044 | // 4.1.36-otjld-callin-method-with-super-1 |
| 6045 | public void test4136_callinMethodWithSuper1() { |
| 6046 | |
| 6047 | runConformTest( |
| 6048 | new String[] { |
| 6049 | "Team4136cmws1.java", |
| 6050 | "\n" + |
| 6051 | "public team class Team4136cmws1 {\n" + |
| 6052 | " protected class R1 playedBy T4136cmws1 {\n" + |
| 6053 | " @SuppressWarnings(\"basecall\")\n" + |
| 6054 | " callin void ci () {\n" + |
| 6055 | " System.out.print(\"K\");\n" + |
| 6056 | " }\n" + |
| 6057 | " ci <- replace fubar;\n" + |
| 6058 | " }\n" + |
| 6059 | " protected class R2 extends R1 {\n" + |
| 6060 | " callin void ci () {\n" + |
| 6061 | " System.out.print(\"O\");\n" + |
| 6062 | " super.ci();\n" + |
| 6063 | " base.ci();\n" + |
| 6064 | " }\n" + |
| 6065 | " }\n" + |
| 6066 | " public static void main(String[] args) {\n" + |
| 6067 | " new Team4136cmws1().activate();\n" + |
| 6068 | " new T4136cmws1().fubar();\n" + |
| 6069 | " }\n" + |
| 6070 | "} \n" + |
| 6071 | " \n", |
| 6072 | "T4136cmws1.java", |
| 6073 | "\n" + |
| 6074 | "public class T4136cmws1 {\n" + |
| 6075 | " void fubar() {}\n" + |
| 6076 | "} \n" + |
| 6077 | " \n" |
| 6078 | }, |
| 6079 | "OK"); |
| 6080 | } |
| 6081 | |
| 6082 | // a callin method calls its implicit super method |
| 6083 | // 4.1.36-otjld-callin-method-with-super-2 |
| 6084 | public void test4136_callinMethodWithSuper2() { |
| 6085 | |
| 6086 | runConformTest( |
| 6087 | new String[] { |
| 6088 | "Team4136cmws2_2.java", |
| 6089 | " \n" + |
| 6090 | "public team class Team4136cmws2_2 extends Team4136cmws2_1 {\n" + |
| 6091 | " protected class R1 {\n" + |
| 6092 | " callin void ci () {\n" + |
| 6093 | " System.out.print(\"O\");\n" + |
| 6094 | " tsuper.ci();\n" + |
| 6095 | " base.ci();\n" + |
| 6096 | " }\n" + |
| 6097 | " }\n" + |
| 6098 | " public static void main(String[] args) {\n" + |
| 6099 | " new Team4136cmws2_2().activate();\n" + |
| 6100 | " new T4136cmws2().fubar();\n" + |
| 6101 | " }\n" + |
| 6102 | "} \n" + |
| 6103 | " \n", |
| 6104 | "T4136cmws2.java", |
| 6105 | "\n" + |
| 6106 | "public class T4136cmws2 {\n" + |
| 6107 | " void fubar() {}\n" + |
| 6108 | "} \n" + |
| 6109 | " \n", |
| 6110 | "Team4136cmws2_1.java", |
| 6111 | "\n" + |
| 6112 | "public team class Team4136cmws2_1 {\n" + |
| 6113 | " protected class R1 playedBy T4136cmws2 {\n" + |
| 6114 | " @SuppressWarnings(\"basecall\")\n" + |
| 6115 | " callin void ci () {\n" + |
| 6116 | " System.out.print(\"K\");\n" + |
| 6117 | " }\n" + |
| 6118 | " ci <- replace fubar;\n" + |
| 6119 | " }\n" + |
| 6120 | "}\n" + |
| 6121 | " \n" |
| 6122 | }, |
| 6123 | "OK"); |
| 6124 | } |
| 6125 | |
| 6126 | // a callin method calls its implicit super method which contains a base-call |
| 6127 | // 4.1.36-otjld-callin-method-with-super-3 |
| 6128 | public void test4136_callinMethodWithSuper3() { |
| 6129 | |
| 6130 | runConformTest( |
| 6131 | new String[] { |
| 6132 | "Team4136cmws3_2.java", |
| 6133 | " \n" + |
| 6134 | "public team class Team4136cmws3_2 extends Team4136cmws3_1 {\n" + |
| 6135 | " protected class R1 {\n" + |
| 6136 | " callin void ci () {\n" + |
| 6137 | " System.out.print(\"O\");\n" + |
| 6138 | " tsuper.ci();\n" + |
| 6139 | " }\n" + |
| 6140 | " }\n" + |
| 6141 | " public static void main(String[] args) {\n" + |
| 6142 | " new Team4136cmws3_2().activate();\n" + |
| 6143 | " new T4136cmws3().fubar();\n" + |
| 6144 | " }\n" + |
| 6145 | "} \n" + |
| 6146 | " \n", |
| 6147 | "T4136cmws3.java", |
| 6148 | "\n" + |
| 6149 | "public class T4136cmws3 {\n" + |
| 6150 | " void fubar() {\n" + |
| 6151 | " System.out.print(\"!\");\n" + |
| 6152 | " }\n" + |
| 6153 | "} \n" + |
| 6154 | " \n", |
| 6155 | "Team4136cmws3_1.java", |
| 6156 | "\n" + |
| 6157 | "public team class Team4136cmws3_1 {\n" + |
| 6158 | " protected class R1 playedBy T4136cmws3 {\n" + |
| 6159 | " callin void ci () {\n" + |
| 6160 | " System.out.print(\"K\");\n" + |
| 6161 | " base.ci();\n" + |
| 6162 | " }\n" + |
| 6163 | " ci <- replace fubar;\n" + |
| 6164 | " }\n" + |
| 6165 | "}\n" + |
| 6166 | " \n" |
| 6167 | }, |
| 6168 | "OK!"); |
| 6169 | } |
| 6170 | |
| 6171 | // a replace callin requires OTJLD 2.3.3(a) for compatibility, which is, however, not reversible |
| 6172 | // 4.1.37-otjld-incompatible-callin-binding-1 |
| 6173 | public void test4137_incompatibleCallinBinding1() { |
| 6174 | runNegativeTestMatching( |
| 6175 | new String[] { |
| 6176 | "Team4137icb1.java", |
| 6177 | "\n" + |
| 6178 | "public team class Team4137icb1 {\n" + |
| 6179 | " protected class R1 { \n" + |
| 6180 | " callin void bar(R1 r){\n" + |
| 6181 | " base.bar(r); // OTRE generates access to inexistent r._OT$base (when seen through the binding below)\n" + |
| 6182 | " }\n" + |
| 6183 | " }\n" + |
| 6184 | " protected class R2 extends R1 playedBy T4137icb1 {\n" + |
| 6185 | " bar <- replace foo;\n" + |
| 6186 | " }\n" + |
| 6187 | " public static void main(String[] args) {\n" + |
| 6188 | " new Team4137icb1().activate();\n" + |
| 6189 | " T4137icb1 b = new T4137icb1();\n" + |
| 6190 | " b.foo(b);\n" + |
| 6191 | " }\n" + |
| 6192 | "}\n" + |
| 6193 | " \n", |
| 6194 | "T4137icb1.java", |
| 6195 | "\n" + |
| 6196 | "public class T4137icb1 {\n" + |
| 6197 | " void foo(T4137icb1 b) {}\n" + |
| 6198 | "}\n" + |
| 6199 | " \n" |
| 6200 | }, |
| 6201 | "4.5(d)"); |
| 6202 | } |
| 6203 | |
| 6204 | // a callin binding to an inherited final method would require to override the final method |
| 6205 | // 4.1.38-otjld-callin-to-final-1 |
| 6206 | public void test4138_callinToFinal1() { |
| 6207 | runNegativeTestMatching( |
| 6208 | new String[] { |
| 6209 | "Team4138ctf1.java", |
| 6210 | "\n" + |
| 6211 | "public team class Team4138ctf1 {\n" + |
| 6212 | " protected class R playedBy T4138ctf1_2 {\n" + |
| 6213 | " void k() {\n" + |
| 6214 | " System.out.print(\"K\");\n" + |
| 6215 | " }\n" + |
| 6216 | " k <- after test;\n" + |
| 6217 | " }\n" + |
| 6218 | " // for running the class and observing:\n" + |
| 6219 | " // \"VerifyError: class T4138ctf1_2 overrides final method\"\n" + |
| 6220 | " public static void main(String[] args) {} \n" + |
| 6221 | "}\n" + |
| 6222 | " \n", |
| 6223 | "T4138ctf1_1.java", |
| 6224 | "\n" + |
| 6225 | "public class T4138ctf1_1 {\n" + |
| 6226 | " final void test() {\n" + |
| 6227 | " System.out.print(\"O\");\n" + |
| 6228 | " }\n" + |
| 6229 | "}\n" + |
| 6230 | " \n", |
| 6231 | "T4138ctf1_2.java", |
| 6232 | "\n" + |
| 6233 | "public class T4138ctf1_2 extends T4138ctf1_1 {\n" + |
| 6234 | "}\n" + |
| 6235 | " \n" |
| 6236 | }, |
| 6237 | "4.1(f)"); |
| 6238 | } |
| 6239 | |
| 6240 | // a callin binding to an inherited final method; correctly adapting the super-base |
| 6241 | // 4.1.38-otjld-callin-to-final-2 |
| 6242 | public void test4138_callinToFinal2() { |
| 6243 | |
| 6244 | runConformTest( |
| 6245 | new String[] { |
| 6246 | "Team4138ctf2.java", |
| 6247 | "\n" + |
| 6248 | "public team class Team4138ctf2 {\n" + |
| 6249 | " protected class R0 playedBy T4138ctf2_1 {\n" + |
| 6250 | " void k() {}; // cannot declare abstract because R0 is relevant!\n" + |
| 6251 | " k <- after test;\n" + |
| 6252 | " }\n" + |
| 6253 | " protected class R1 extends R0 playedBy T4138ctf2_2 {\n" + |
| 6254 | " void k() {\n" + |
| 6255 | " System.out.print(\"K\");\n" + |
| 6256 | " }\n" + |
| 6257 | " }\n" + |
| 6258 | " public static void main(String[] args) {\n" + |
| 6259 | " new Team4138ctf2().activate();\n" + |
| 6260 | " new T4138ctf2_2().test();\n" + |
| 6261 | " }\n" + |
| 6262 | "}\n" + |
| 6263 | " \n", |
| 6264 | "T4138ctf2_1.java", |
| 6265 | "\n" + |
| 6266 | "public class T4138ctf2_1 {\n" + |
| 6267 | " final void test() {\n" + |
| 6268 | " System.out.print(\"O\");\n" + |
| 6269 | " }\n" + |
| 6270 | "}\n" + |
| 6271 | " \n", |
| 6272 | "T4138ctf2_2.java", |
| 6273 | "\n" + |
| 6274 | "public class T4138ctf2_2 extends T4138ctf2_1 {\n" + |
| 6275 | "}\n" + |
| 6276 | " \n" |
| 6277 | }, |
| 6278 | "OK"); |
| 6279 | } |
| 6280 | |
| 6281 | // multiple different callins from different teams to the same base method |
| 6282 | // 4.1.38-otjld-multiple-callin-1 |
| 6283 | public void test4138_multipleCallin1() { |
| 6284 | |
| 6285 | runConformTest( |
| 6286 | new String[] { |
| 6287 | "T4138mc1Main.java", |
| 6288 | "\n" + |
| 6289 | "public class T4138mc1Main {\n" + |
| 6290 | " public static void main(String[] args) {\n" + |
| 6291 | " new Team4138mc1_1().activate();\n" + |
| 6292 | " new Team4138mc1_2().activate();\n" + |
| 6293 | " new T4138mc1().test();\n" + |
| 6294 | " }\n" + |
| 6295 | "}\n" + |
| 6296 | " \n", |
| 6297 | "T4138mc1.java", |
| 6298 | "\n" + |
| 6299 | "public class T4138mc1 {\n" + |
| 6300 | " public void test() {\n" + |
| 6301 | " System.out.print(\"K\");\n" + |
| 6302 | " }\n" + |
| 6303 | "}\n" + |
| 6304 | " \n", |
| 6305 | "Team4138mc1_1.java", |
| 6306 | "\n" + |
| 6307 | "public team class Team4138mc1_1 {\n" + |
| 6308 | " protected class R playedBy T4138mc1 {\n" + |
| 6309 | " callin void t() {\n" + |
| 6310 | " base.t();\n" + |
| 6311 | " System.out.print(\"!\");\n" + |
| 6312 | " }\n" + |
| 6313 | " t <- replace test;\n" + |
| 6314 | " }\n" + |
| 6315 | "}\n" + |
| 6316 | " \n", |
| 6317 | "Team4138mc1_2.java", |
| 6318 | "\n" + |
| 6319 | "public team class Team4138mc1_2 {\n" + |
| 6320 | " protected class R playedBy T4138mc1 {\n" + |
| 6321 | " void u() {\n" + |
| 6322 | " System.out.print(\"O\");\n" + |
| 6323 | " }\n" + |
| 6324 | " u <- before test;\n" + |
| 6325 | " }\n" + |
| 6326 | "}\n" + |
| 6327 | " \n" |
| 6328 | }, |
| 6329 | "OK!"); |
| 6330 | } |
| 6331 | |
| 6332 | // multiple different callins from different teams to the same base method - base inheritance |
| 6333 | // 4.1.38-otjld-multiple-callin-2 |
| 6334 | public void test4138_multipleCallin2() { |
| 6335 | |
| 6336 | runConformTest( |
| 6337 | new String[] { |
| 6338 | "T4138mc2Main.java", |
| 6339 | "\n" + |
| 6340 | "public class T4138mc2Main {\n" + |
| 6341 | " public static void main(String[] args) {\n" + |
| 6342 | " new Team4138mc2_1().activate();\n" + |
| 6343 | " new Team4138mc2_2().activate();\n" + |
| 6344 | " new T4138mc2_2().test();\n" + |
| 6345 | " }\n" + |
| 6346 | "}\n" + |
| 6347 | " \n", |
| 6348 | "T4138mc2_1.java", |
| 6349 | "\n" + |
| 6350 | "public class T4138mc2_1 {\n" + |
| 6351 | " public void test() {\n" + |
| 6352 | " System.out.print(\"K\");\n" + |
| 6353 | " }\n" + |
| 6354 | "}\n" + |
| 6355 | " \n", |
| 6356 | "T4138mc2_2.java", |
| 6357 | "\n" + |
| 6358 | "public class T4138mc2_2 extends T4138mc2_1 {}\n" + |
| 6359 | " \n", |
| 6360 | "Team4138mc2_1.java", |
| 6361 | "\n" + |
| 6362 | "public team class Team4138mc2_1 {\n" + |
| 6363 | " protected class R playedBy T4138mc2_1 {\n" + |
| 6364 | " callin void t() {\n" + |
| 6365 | " base.t();\n" + |
| 6366 | " System.out.print(\"!\");\n" + |
| 6367 | " }\n" + |
| 6368 | " t <- replace test;\n" + |
| 6369 | " }\n" + |
| 6370 | "}\n" + |
| 6371 | " \n", |
| 6372 | "Team4138mc2_2.java", |
| 6373 | "\n" + |
| 6374 | "public team class Team4138mc2_2 {\n" + |
| 6375 | " protected class R playedBy T4138mc2_2 {\n" + |
| 6376 | " void u() {\n" + |
| 6377 | " System.out.print(\"O\");\n" + |
| 6378 | " }\n" + |
| 6379 | " u <- before test;\n" + |
| 6380 | " }\n" + |
| 6381 | "}\n" + |
| 6382 | " \n" |
| 6383 | }, |
| 6384 | "OK!"); |
| 6385 | } |
| 6386 | |
Stephan Herrmann | ebcc8eb | 2011-01-04 19:37:11 +0000 | [diff] [blame] | 6387 | // multiple different callins from different teams to the same base method - base inheritance |
| 6388 | // simplified load order: load base before teams. |
| 6389 | public void test4138_multipleCallin2l() { |
| 6390 | |
| 6391 | runConformTest( |
| 6392 | new String[] { |
| 6393 | "T4138mc2lMain.java", |
| 6394 | "\n" + |
| 6395 | "public class T4138mc2lMain {\n" + |
| 6396 | " public static void main(String[] args) {\n" + |
| 6397 | " T4138mc2l_2 t = new T4138mc2l_2();" + |
| 6398 | " new Team4138mc2l_1().activate();\n" + |
| 6399 | " new Team4138mc2l_2().activate();\n" + |
| 6400 | " t.test();\n" + |
| 6401 | " }\n" + |
| 6402 | "}\n" + |
| 6403 | " \n", |
| 6404 | "T4138mc2l_1.java", |
| 6405 | "\n" + |
| 6406 | "public class T4138mc2l_1 {\n" + |
| 6407 | " public void test() {\n" + |
| 6408 | " System.out.print(\"K\");\n" + |
| 6409 | " }\n" + |
| 6410 | "}\n" + |
| 6411 | " \n", |
| 6412 | "T4138mc2l_2.java", |
| 6413 | "\n" + |
| 6414 | "public class T4138mc2l_2 extends T4138mc2l_1 {}\n" + |
| 6415 | " \n", |
| 6416 | "Team4138mc2l_1.java", |
| 6417 | "\n" + |
| 6418 | "public team class Team4138mc2l_1 {\n" + |
| 6419 | " protected class R playedBy T4138mc2l_1 {\n" + |
| 6420 | " callin void t() {\n" + |
| 6421 | " base.t();\n" + |
| 6422 | " System.out.print(\"!\");\n" + |
| 6423 | " }\n" + |
| 6424 | " t <- replace test;\n" + |
| 6425 | " }\n" + |
| 6426 | "}\n" + |
| 6427 | " \n", |
| 6428 | "Team4138mc2l_2.java", |
| 6429 | "\n" + |
| 6430 | "public team class Team4138mc2l_2 {\n" + |
| 6431 | " protected class R playedBy T4138mc2l_2 {\n" + |
| 6432 | " void u() {\n" + |
| 6433 | " System.out.print(\"O\");\n" + |
| 6434 | " }\n" + |
| 6435 | " u <- before test;\n" + |
| 6436 | " }\n" + |
| 6437 | "}\n" + |
| 6438 | " \n" |
| 6439 | }, |
| 6440 | "OK!"); |
| 6441 | } |
| 6442 | |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 6443 | // multiple replaces ordered by precedence plus before/after - reported by ofrank |
| 6444 | // 4.1.38-otjld-multiple-callin-3 |
| 6445 | public void test4138_multipleCallin3() { |
| 6446 | |
| 6447 | runConformTest( |
| 6448 | new String[] { |
| 6449 | "Team4138mc3.java", |
| 6450 | "\n" + |
| 6451 | "public team class Team4138mc3 {\n" + |
| 6452 | " static String indent = \"\";\n" + |
| 6453 | " String name;\n" + |
| 6454 | " Team4138mc3 (String name) {\n" + |
| 6455 | " this.name = name;\n" + |
| 6456 | " }\n" + |
| 6457 | " precedence R1, R0;\n" + |
| 6458 | " public class R0 playedBy T4138mc3 {\n" + |
| 6459 | " public void beforeMethod() {\n" + |
| 6460 | " System.out.println(name+indent+\"R0 before\");\n" + |
| 6461 | " }\n" + |
| 6462 | "\n" + |
| 6463 | " callin void replaceMethod() {\n" + |
| 6464 | " System.out.println(name+indent+\">>>R0 replace\");\n" + |
| 6465 | " String ind = indent;\n" + |
| 6466 | " indent = indent + \" \";\n" + |
| 6467 | " base.replaceMethod();\n" + |
| 6468 | " indent = ind;\n" + |
| 6469 | " System.out.println(name+indent+\"<<<R0 replace\");\n" + |
| 6470 | " }\n" + |
| 6471 | "\n" + |
| 6472 | " public void afterMethod() {\n" + |
| 6473 | " System.out.println(name+indent+\"R0 after\");\n" + |
| 6474 | " }\n" + |
| 6475 | "\n" + |
| 6476 | " replaceMethod <- replace abc;\n" + |
| 6477 | "\n" + |
| 6478 | " beforeMethod <- before abc;\n" + |
| 6479 | "\n" + |
| 6480 | " afterMethod <- after abc;\n" + |
| 6481 | "\n" + |
| 6482 | " }\n" + |
| 6483 | "\n" + |
| 6484 | " protected class R1 playedBy T4138mc3 {\n" + |
| 6485 | " callin void replaceMethod() {\n" + |
| 6486 | " System.out.println(name+indent+\">>>R1 replace\");\n" + |
| 6487 | " String ind = indent;\n" + |
| 6488 | " indent = indent + \" \";\n" + |
| 6489 | " base.replaceMethod();\n" + |
| 6490 | " indent = ind;\n" + |
| 6491 | " System.out.println(name+indent+\"<<<R1 replace\");\n" + |
| 6492 | " }\n" + |
| 6493 | "\n" + |
| 6494 | " replaceMethod <- replace abc;\n" + |
| 6495 | " }\n" + |
| 6496 | " public static void main(String[] args) {\n" + |
| 6497 | " new Team4138mc3(\"XXX\").activate();\n" + |
| 6498 | " new Team4138mc3(\"YYY\").activate();\n" + |
| 6499 | " new T4138mc3().abc();\n" + |
| 6500 | " }\n" + |
| 6501 | "}\n" + |
| 6502 | " \n", |
| 6503 | "T4138mc3.java", |
| 6504 | "\n" + |
| 6505 | "public class T4138mc3 {\n" + |
| 6506 | " public void abc () { System.out.println(\"base method\"); }\n" + |
| 6507 | "}\n" + |
| 6508 | " \n" |
| 6509 | }, |
| 6510 | "YYYR0 before\n" + |
| 6511 | "YYY>>>R1 replace\n" + |
| 6512 | "YYY >>>R0 replace\n" + |
| 6513 | "XXX R0 before\n" + |
| 6514 | "XXX >>>R1 replace\n" + |
| 6515 | "XXX >>>R0 replace\n" + |
| 6516 | "base method\n" + |
| 6517 | "XXX <<<R0 replace\n" + |
| 6518 | "XXX <<<R1 replace\n" + |
| 6519 | "XXX R0 after\n" + |
| 6520 | "YYY <<<R0 replace\n" + |
| 6521 | "YYY<<<R1 replace\n" + |
| 6522 | "YYYR0 after"); |
| 6523 | } |
| 6524 | |
| 6525 | // a callin binding intercepts a method that has an override with covariant return - static type is super-base |
| 6526 | // 4.1.39-otjld-callin-binding-with-plus-1 |
| 6527 | public void test4139_callinBindingWithPlus1() { |
| 6528 | |
| 6529 | runConformTest( |
| 6530 | new String[] { |
| 6531 | "Team4139cbwp1.java", |
| 6532 | "\n" + |
| 6533 | "public team class Team4139cbwp1 {\n" + |
| 6534 | " protected class R playedBy T4139cbwp1_1 {\n" + |
| 6535 | " void k() { System.out.print(\"O\"); }\n" + |
| 6536 | " void k() <- after T4139cbwp1_1+ getOther();\n" + |
| 6537 | " }\n" + |
| 6538 | " public static void main(String[] args) {\n" + |
| 6539 | " new Team4139cbwp1().activate();\n" + |
| 6540 | " T4139cbwp1_1 b = new T4139cbwp1_2();\n" + |
| 6541 | " b = b.getOther();\n" + |
| 6542 | " b.test();\n" + |
| 6543 | " }\n" + |
| 6544 | "}\n" + |
| 6545 | " \n", |
| 6546 | "T4139cbwp1_1.java", |
| 6547 | "\n" + |
| 6548 | "public class T4139cbwp1_1 {\n" + |
| 6549 | " T4139cbwp1_1 getOther() { return this; }\n" + |
| 6550 | " void test() { System.out.print(\"X\"); }\n" + |
| 6551 | "}\n" + |
| 6552 | " \n", |
| 6553 | "T4139cbwp1_2.java", |
| 6554 | "\n" + |
| 6555 | "public class T4139cbwp1_2 extends T4139cbwp1_1 {\n" + |
| 6556 | " @Override\n" + |
| 6557 | " T4139cbwp1_2 getOther() { return this; }\n" + |
| 6558 | " void test() { System.out.print(\"K\"); }\n" + |
| 6559 | "}\n" + |
| 6560 | " \n" |
| 6561 | }, |
| 6562 | "OK"); |
| 6563 | } |
| 6564 | |
Stephan Herrmann | 43eadd6 | 2011-01-10 23:17:09 +0000 | [diff] [blame] | 6565 | // a callin binding intercepts a method that has an override with covariant return - static type is super-base - no plus used |
| 6566 | public void test4139_callinBindingWithPlus1a() { |
| 6567 | |
| 6568 | runConformTest( |
| 6569 | new String[] { |
| 6570 | "Team4139cbwp1a.java", |
| 6571 | "\n" + |
| 6572 | "public team class Team4139cbwp1a {\n" + |
| 6573 | " protected class R playedBy T4139cbwp1a_1 {\n" + |
| 6574 | " void k() { System.out.print(\"O\"); }\n" + |
| 6575 | " void k() <- after T4139cbwp1a_1 getOther();\n" + |
| 6576 | " }\n" + |
| 6577 | " public static void main(String[] args) {\n" + |
| 6578 | " new Team4139cbwp1a().activate();\n" + |
| 6579 | " T4139cbwp1a_1 b = new T4139cbwp1a_2();\n" + |
| 6580 | " b = b.getOther();\n" + |
| 6581 | " b.test();\n" + |
| 6582 | " }\n" + |
| 6583 | "}\n" + |
| 6584 | " \n", |
| 6585 | "T4139cbwp1a_1.java", |
| 6586 | "\n" + |
| 6587 | "public class T4139cbwp1a_1 {\n" + |
| 6588 | " T4139cbwp1a_1 getOther() { return this; }\n" + |
| 6589 | " void test() { System.out.print(\"X\"); }\n" + |
| 6590 | "}\n" + |
| 6591 | " \n", |
| 6592 | "T4139cbwp1a_2.java", |
| 6593 | "\n" + |
| 6594 | "public class T4139cbwp1a_2 extends T4139cbwp1a_1 {\n" + |
| 6595 | " @Override\n" + |
| 6596 | " T4139cbwp1a_2 getOther() { return this; }\n" + |
| 6597 | " void test() { System.out.print(\"K\"); }\n" + |
| 6598 | "}\n" + |
| 6599 | " \n" |
| 6600 | }, |
| 6601 | "K"); |
| 6602 | } |
| 6603 | |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 6604 | // a callin binding intercepts a method that has an override with covariant return - static type is sub-base |
| 6605 | // 4.1.39-otjld-callin-binding-with-plus-2 |
| 6606 | public void test4139_callinBindingWithPlus2() { |
| 6607 | |
| 6608 | runConformTest( |
| 6609 | new String[] { |
| 6610 | "Team4139cbwp2.java", |
| 6611 | "\n" + |
| 6612 | "public team class Team4139cbwp2 {\n" + |
| 6613 | " protected class R playedBy T4139cbwp2_1 {\n" + |
| 6614 | " void k() { System.out.print(\"O\"); }\n" + |
| 6615 | " void k() <- after T4139cbwp2_1+ getOther();\n" + |
| 6616 | " }\n" + |
| 6617 | " public static void main(String[] args) {\n" + |
| 6618 | " new Team4139cbwp2().activate();\n" + |
| 6619 | " T4139cbwp2_2 b = new T4139cbwp2_2();\n" + |
| 6620 | " b = b.getOther();\n" + |
| 6621 | " b.test();\n" + |
| 6622 | " }\n" + |
| 6623 | "}\n" + |
| 6624 | " \n", |
| 6625 | "T4139cbwp2_1.java", |
| 6626 | "\n" + |
| 6627 | "public class T4139cbwp2_1 {\n" + |
| 6628 | " T4139cbwp2_1 getOther() { return this; }\n" + |
| 6629 | " void test() { System.out.print(\"X\"); }\n" + |
| 6630 | "}\n" + |
| 6631 | " \n", |
| 6632 | "T4139cbwp2_2.java", |
| 6633 | "\n" + |
| 6634 | "public class T4139cbwp2_2 extends T4139cbwp2_1 {\n" + |
| 6635 | " @Override\n" + |
| 6636 | " T4139cbwp2_2 getOther() { return this; }\n" + |
| 6637 | " void test() { System.out.print(\"K\"); }\n" + |
| 6638 | "}\n" + |
| 6639 | " \n" |
| 6640 | }, |
| 6641 | "OK"); |
| 6642 | } |
| 6643 | |
| 6644 | // replace callin to base methods with covariant return types |
| 6645 | // 4.1.39-otjld-callin-binding-with-plus-3 |
| 6646 | public void test4139_callinBindingWithPlus3() { |
| 6647 | |
| 6648 | runConformTest( |
| 6649 | new String[] { |
| 6650 | "Team4139cbwp3.java", |
| 6651 | "\n" + |
| 6652 | "public team class Team4139cbwp3 {\n" + |
| 6653 | " protected class R playedBy T4139cbwp3_1 {\n" + |
| 6654 | " callin <T extends T4139cbwp3_1> T k() { \n" + |
| 6655 | " System.out.print(\"O\");\n" + |
| 6656 | " return base.k();\n" + |
| 6657 | " }\n" + |
| 6658 | " <T extends T4139cbwp3_1> T k() <- replace T4139cbwp3_1+ getOther();\n" + |
| 6659 | " }\n" + |
| 6660 | " public static void main(String[] args) {\n" + |
| 6661 | " new Team4139cbwp3().activate();\n" + |
| 6662 | " T4139cbwp3_2 b = new T4139cbwp3_2();\n" + |
| 6663 | " b = b.getOther();\n" + |
| 6664 | " b.test();\n" + |
| 6665 | " }\n" + |
| 6666 | "}\n" + |
| 6667 | " \n", |
| 6668 | "T4139cbwp3_1.java", |
| 6669 | "\n" + |
| 6670 | "public class T4139cbwp3_1 {\n" + |
| 6671 | " T4139cbwp3_1 getOther() { return this; }\n" + |
| 6672 | "}\n" + |
| 6673 | " \n", |
| 6674 | "T4139cbwp3_2.java", |
| 6675 | "\n" + |
| 6676 | "public class T4139cbwp3_2 extends T4139cbwp3_1 {\n" + |
| 6677 | " @Override\n" + |
| 6678 | " T4139cbwp3_2 getOther() { return this; }\n" + |
| 6679 | " void test() { System.out.print(\"K\"); }\n" + |
| 6680 | "}\n" + |
| 6681 | " \n" |
| 6682 | }, |
| 6683 | "OK"); |
| 6684 | } |
| 6685 | |
| 6686 | // replace callin to base methods with covariant return types, invoked on super-base as the static type |
| 6687 | // 4.1.39-otjld-callin-binding-with-plus-4 |
| 6688 | public void test4139_callinBindingWithPlus4() { |
| 6689 | |
| 6690 | runConformTest( |
| 6691 | new String[] { |
| 6692 | "Team4139cbwp4.java", |
| 6693 | "\n" + |
| 6694 | "public team class Team4139cbwp4 {\n" + |
| 6695 | " protected class R playedBy T4139cbwp4_1 {\n" + |
| 6696 | " callin <T extends T4139cbwp4_1> T k() { \n" + |
| 6697 | " System.out.print(\"O\");\n" + |
| 6698 | " return base.k();\n" + |
| 6699 | " }\n" + |
| 6700 | " <T extends T4139cbwp4_1> T k() <- replace T4139cbwp4_1+ getOther();\n" + |
| 6701 | " }\n" + |
| 6702 | " public static void main(String[] args) {\n" + |
| 6703 | " new Team4139cbwp4().activate();\n" + |
| 6704 | " T4139cbwp4_1 b = new T4139cbwp4_2();\n" + |
| 6705 | " b = b.getOther();\n" + |
| 6706 | " ((T4139cbwp4_2)b).test();\n" + |
| 6707 | " }\n" + |
| 6708 | "}\n" + |
| 6709 | " \n", |
| 6710 | "T4139cbwp4_1.java", |
| 6711 | "\n" + |
| 6712 | "public class T4139cbwp4_1 {\n" + |
| 6713 | " T4139cbwp4_1 getOther() { return this; }\n" + |
| 6714 | "}\n" + |
| 6715 | " \n", |
| 6716 | "T4139cbwp4_2.java", |
| 6717 | "\n" + |
| 6718 | "public class T4139cbwp4_2 extends T4139cbwp4_1 {\n" + |
| 6719 | " @Override\n" + |
| 6720 | " T4139cbwp4_2 getOther() { return this; }\n" + |
| 6721 | " void test() { System.out.print(\"K\"); }\n" + |
| 6722 | "}\n" + |
| 6723 | " \n" |
| 6724 | }, |
| 6725 | "OK"); |
| 6726 | } |
| 6727 | |
| 6728 | // replace callin to base methods with covariant return types, incompatible return in callin method |
| 6729 | // 4.1.39-otjld-callin-binding-with-plus-5 |
| 6730 | public void test4139_callinBindingWithPlus5() { |
| 6731 | runNegativeTestMatching( |
| 6732 | new String[] { |
| 6733 | "Team4139cbwp5.java", |
| 6734 | "\n" + |
| 6735 | "public team class Team4139cbwp5 {\n" + |
| 6736 | " protected class R playedBy T4139cbwp5_1 {\n" + |
| 6737 | " callin <T extends T4139cbwp5_1> T k() { \n" + |
| 6738 | " System.out.print(\"O\");\n" + |
| 6739 | " return new T4139cbwp5_1();\n" + |
| 6740 | " }\n" + |
| 6741 | " <T extends T4139cbwp5_1> T k() <- replace T4139cbwp5_1+ getOther();\n" + |
| 6742 | " }\n" + |
| 6743 | "}\n" + |
| 6744 | " \n", |
| 6745 | "T4139cbwp5_1.java", |
| 6746 | "\n" + |
| 6747 | "public class T4139cbwp5_1 {\n" + |
| 6748 | " T4139cbwp5_1 getOther() { return this; }\n" + |
| 6749 | "}\n" + |
| 6750 | " \n" |
| 6751 | }, |
| 6752 | "cannot convert"); |
| 6753 | } |
| 6754 | |
| 6755 | // replace callin to base methods with covariant return types, same as -5 but not using generics |
| 6756 | // 4.1.39-otjld-callin-binding-with-plus-6 |
| 6757 | public void test4139_callinBindingWithPlus6() { |
| 6758 | runNegativeTestMatching( |
| 6759 | new String[] { |
| 6760 | "Team4139cbwp6.java", |
| 6761 | "\n" + |
| 6762 | "public team class Team4139cbwp6 {\n" + |
| 6763 | " protected class R playedBy T4139cbwp6_1 {\n" + |
| 6764 | " @SuppressWarnings(\"basecall\")\n" + |
| 6765 | " callin T4139cbwp6_1 k() { \n" + |
| 6766 | " System.out.print(\"O\");\n" + |
| 6767 | " return new T4139cbwp6_1();\n" + |
| 6768 | " }\n" + |
| 6769 | " T4139cbwp6_1 k() <- replace T4139cbwp6_1+ getOther();\n" + |
| 6770 | " }\n" + |
| 6771 | "}\n" + |
| 6772 | " \n", |
| 6773 | "T4139cbwp6_1.java", |
| 6774 | "\n" + |
| 6775 | "public class T4139cbwp6_1 {\n" + |
| 6776 | " T4139cbwp6_1 getOther() { return this; }\n" + |
| 6777 | "}\n" + |
| 6778 | " \n" |
| 6779 | }, |
| 6780 | "4.9.3(c)"); |
| 6781 | } |
| 6782 | |
| 6783 | // replace callin to base methods with covariant return types, same as -5 but role methods is not using generics (callin binding however is) |
| 6784 | // 4.1.39-otjld-callin-binding-with-plus-7 |
| 6785 | public void test4139_callinBindingWithPlus7() { |
| 6786 | runNegativeTestMatching( |
| 6787 | new String[] { |
| 6788 | "Team4139cbwp7.java", |
| 6789 | "\n" + |
| 6790 | "public team class Team4139cbwp7 {\n" + |
| 6791 | " protected class R playedBy T4139cbwp7_1 {\n" + |
| 6792 | " @SuppressWarnings(\"basecall\")\n" + |
| 6793 | " callin T4139cbwp7_1 k() { \n" + |
| 6794 | " System.out.print(\"O\");\n" + |
| 6795 | " return new T4139cbwp7_1();\n" + |
| 6796 | " }\n" + |
| 6797 | " <T extends T4139cbwp7_1> T k() <- replace T4139cbwp7_1+ getOther();\n" + |
| 6798 | " }\n" + |
| 6799 | "}\n" + |
| 6800 | " \n", |
| 6801 | "T4139cbwp7_1.java", |
| 6802 | "\n" + |
| 6803 | "public class T4139cbwp7_1 {\n" + |
| 6804 | " T4139cbwp7_1 getOther() { return this; }\n" + |
| 6805 | "}\n" + |
| 6806 | " \n" |
| 6807 | }, |
| 6808 | "4.1(c)"); |
| 6809 | } |
| 6810 | |
| 6811 | // replace callin to base methods with covariant return types, base call result is stored and modified |
| 6812 | // 4.1.39-otjld-callin-binding-with-plus-8 |
| 6813 | public void test4139_callinBindingWithPlus8() { |
| 6814 | |
| 6815 | runConformTest( |
| 6816 | new String[] { |
| 6817 | "Team4139cbwp8.java", |
| 6818 | "\n" + |
| 6819 | "public team class Team4139cbwp8 {\n" + |
| 6820 | " protected class R playedBy T4139cbwp8_1 {\n" + |
| 6821 | " callin <T extends T4139cbwp8_1> T k() { \n" + |
| 6822 | " System.out.print(\"O\");\n" + |
| 6823 | " T result= base.k();\n" + |
| 6824 | " result.setVal(\"K\");\n" + |
| 6825 | " return result;\n" + |
| 6826 | " }\n" + |
| 6827 | " <T extends T4139cbwp8_1> T k() <- replace T4139cbwp8_1+ getOther();\n" + |
| 6828 | " }\n" + |
| 6829 | " public static void main(String[] args) {\n" + |
| 6830 | " new Team4139cbwp8().activate();\n" + |
| 6831 | " T4139cbwp8_1 b = new T4139cbwp8_2();\n" + |
| 6832 | " b = b.getOther();\n" + |
| 6833 | " ((T4139cbwp8_2)b).test();\n" + |
| 6834 | " }\n" + |
| 6835 | "}\n" + |
| 6836 | " \n", |
| 6837 | "T4139cbwp8_1.java", |
| 6838 | "\n" + |
| 6839 | "public abstract class T4139cbwp8_1 {\n" + |
| 6840 | " T4139cbwp8_1 getOther() { return this; }\n" + |
| 6841 | " abstract void setVal(String val);\n" + |
| 6842 | "}\n" + |
| 6843 | " \n", |
| 6844 | "T4139cbwp8_2.java", |
| 6845 | "\n" + |
| 6846 | "public class T4139cbwp8_2 extends T4139cbwp8_1 {\n" + |
| 6847 | " String val;\n" + |
| 6848 | " void setVal(String val) {\n" + |
| 6849 | " this.val= val;\n" + |
| 6850 | " }\n" + |
| 6851 | " @Override\n" + |
| 6852 | " T4139cbwp8_2 getOther() { return this; }\n" + |
| 6853 | " void test() { System.out.print(val); }\n" + |
| 6854 | "}\n" + |
| 6855 | " \n" |
| 6856 | }, |
| 6857 | "OK"); |
| 6858 | } |
| 6859 | |
| 6860 | // replace callin to base methods with covariant return types - unbounded type variable |
| 6861 | // 4.1.39-otjld-callin-binding-with-plus-9 |
| 6862 | public void test4139_callinBindingWithPlus9() { |
| 6863 | |
| 6864 | runConformTest( |
| 6865 | new String[] { |
| 6866 | "Team4139cbwp9.java", |
| 6867 | "\n" + |
| 6868 | "public team class Team4139cbwp9 {\n" + |
| 6869 | " protected class R playedBy T4139cbwp9_1 {\n" + |
| 6870 | " callin <T> T k() { \n" + |
| 6871 | " System.out.print(\"O\");\n" + |
| 6872 | " return base.k();\n" + |
| 6873 | " }\n" + |
| 6874 | " <T> T k() <- replace T4139cbwp9_1+ getOther();\n" + |
| 6875 | " }\n" + |
| 6876 | " public static void main(String[] args) {\n" + |
| 6877 | " new Team4139cbwp9().activate();\n" + |
| 6878 | " T4139cbwp9_2 b = new T4139cbwp9_2();\n" + |
| 6879 | " b = b.getOther();\n" + |
| 6880 | " b.test();\n" + |
| 6881 | " }\n" + |
| 6882 | "}\n" + |
| 6883 | " \n", |
| 6884 | "T4139cbwp9_1.java", |
| 6885 | "\n" + |
| 6886 | "public class T4139cbwp9_1 {\n" + |
| 6887 | " T4139cbwp9_1 getOther() { return this; }\n" + |
| 6888 | "}\n" + |
| 6889 | " \n", |
| 6890 | "T4139cbwp9_2.java", |
| 6891 | "\n" + |
| 6892 | "public class T4139cbwp9_2 extends T4139cbwp9_1 {\n" + |
| 6893 | " @Override\n" + |
| 6894 | " T4139cbwp9_2 getOther() { return this; }\n" + |
| 6895 | " void test() { System.out.print(\"K\"); }\n" + |
| 6896 | "}\n" + |
| 6897 | " \n" |
| 6898 | }, |
| 6899 | "OK"); |
| 6900 | } |
| 6901 | |
| 6902 | // base call result is lifting-compatible to type bound |
| 6903 | // 4.1.40-otjld-callin-replace-compatibility-5 |
| 6904 | public void test4140_callinReplaceCompatibility5() { |
| 6905 | |
| 6906 | runConformTest( |
| 6907 | new String[] { |
| 6908 | "Team4140crc5.java", |
| 6909 | "\n" + |
| 6910 | "public team class Team4140crc5 {\n" + |
| 6911 | " protected class R playedBy T4140crc5 {\n" + |
| 6912 | " protected void print() { System.out.print(\"O\"); }\n" + |
| 6913 | " callin <T extends R> T mingle() {\n" + |
| 6914 | " T t= base.mingle();\n" + |
| 6915 | " t.print();\n" + |
| 6916 | " return t;\n" + |
| 6917 | " }\n" + |
| 6918 | " <T extends R> T mingle() <- replace T4140crc5 m();\n" + |
| 6919 | " }\n" + |
| 6920 | " public static void main(String[] args) {\n" + |
| 6921 | " within(new Team4140crc5()) {\n" + |
| 6922 | " System.out.print(new T4140crc5().m());\n" + |
| 6923 | " }\n" + |
| 6924 | " }\n" + |
| 6925 | "}\n" + |
| 6926 | " \n", |
| 6927 | "T4140crc5.java", |
| 6928 | "\n" + |
| 6929 | "public class T4140crc5 {\n" + |
| 6930 | " public T4140crc5 m() {\n" + |
| 6931 | " return new T4140crc5();\n" + |
| 6932 | " }\n" + |
| 6933 | " public String toString() {\n" + |
| 6934 | " return \"K\";\n" + |
| 6935 | " }\n" + |
| 6936 | "}\n" + |
| 6937 | " \n" |
| 6938 | }, |
| 6939 | "OK"); |
| 6940 | } |
| 6941 | |
| 6942 | // base call result is lifting-compatible to exact type -- reference for previous test |
| 6943 | // 4.1.40-otjld-callin-replace-compatibility-6 |
| 6944 | public void test4140_callinReplaceCompatibility6() { |
| 6945 | |
| 6946 | runConformTest( |
| 6947 | new String[] { |
| 6948 | "Team4140crc6.java", |
| 6949 | "\n" + |
| 6950 | "public team class Team4140crc6 {\n" + |
| 6951 | " protected class R playedBy T4140crc6 {\n" + |
| 6952 | " void print() { System.out.print(\"O\"); }\n" + |
| 6953 | " callin R mingle() {\n" + |
| 6954 | " R t= base.mingle();\n" + |
| 6955 | " t.print();\n" + |
| 6956 | " return t;\n" + |
| 6957 | " }\n" + |
| 6958 | " R mingle() <- replace T4140crc6 m();\n" + |
| 6959 | " }\n" + |
| 6960 | " public static void main(String[] args) {\n" + |
| 6961 | " within(new Team4140crc6()) {\n" + |
| 6962 | " System.out.print(new T4140crc6().m());\n" + |
| 6963 | " }\n" + |
| 6964 | " }\n" + |
| 6965 | "}\n" + |
| 6966 | " \n", |
| 6967 | "T4140crc6.java", |
| 6968 | "\n" + |
| 6969 | "public class T4140crc6 {\n" + |
| 6970 | " public T4140crc6 m() {\n" + |
| 6971 | " return new T4140crc6();\n" + |
| 6972 | " }\n" + |
| 6973 | " public String toString() {\n" + |
| 6974 | " return \"K\";\n" + |
| 6975 | " }\n" + |
| 6976 | "}\n" + |
| 6977 | " \n" |
| 6978 | }, |
| 6979 | "OK"); |
| 6980 | } |
| 6981 | |
| 6982 | // a parameter in a replace binding is lifting compatible |
| 6983 | // 4.1.40-otjld-callin-replace-compatibility-7 |
| 6984 | public void test4140_callinReplaceCompatibility7() { |
| 6985 | |
| 6986 | runConformTest( |
| 6987 | new String[] { |
| 6988 | "Team4140crc7.java", |
| 6989 | "\n" + |
| 6990 | "public team class Team4140crc7 {\n" + |
| 6991 | " protected class R playedBy T4140crc7 {\n" + |
| 6992 | " void k() {\n" + |
| 6993 | " System.out.print(\"K\");\n" + |
| 6994 | " }\n" + |
| 6995 | " callin void otherK(R other) {\n" + |
| 6996 | " base.otherK(other);\n" + |
| 6997 | " other.k();\n" + |
| 6998 | " }\n" + |
| 6999 | " otherK <- replace otherO;\n" + |
| 7000 | " }\n" + |
| 7001 | " public static void main(String[] args) {\n" + |
| 7002 | " within (new Team4140crc7()) {\n" + |
| 7003 | " new T4140crc7().otherO(new T4140crc7());\n" + |
| 7004 | " }\n" + |
| 7005 | " }\n" + |
| 7006 | "}\n" + |
| 7007 | " \n", |
| 7008 | "T4140crc7.java", |
| 7009 | "\n" + |
| 7010 | "public class T4140crc7 {\n" + |
| 7011 | " public void o() {\n" + |
| 7012 | " System.out.print(\"O\");\n" + |
| 7013 | " }\n" + |
| 7014 | " public void otherO(T4140crc7 other) {\n" + |
| 7015 | " other.o();\n" + |
| 7016 | " }\n" + |
| 7017 | "}\n" + |
| 7018 | " \n" |
| 7019 | }, |
| 7020 | "OK"); |
| 7021 | } |
| 7022 | |
| 7023 | // the return of a callin method is an unbound thus incompatible role |
| 7024 | // 4.1.40-otjld-callin-replace-compatibility-8 |
| 7025 | public void test4140_callinReplaceCompatibility8() { |
| 7026 | runNegativeTestMatching( |
| 7027 | new String[] { |
| 7028 | "Team4140crc8.java", |
| 7029 | "\n" + |
| 7030 | "public team class Team4140crc8 {\n" + |
| 7031 | " protected class R0 {}\n" + |
| 7032 | " protected class R playedBy T4140crc8 {\n" + |
| 7033 | " void k() {\n" + |
| 7034 | " System.out.print(\"K\");\n" + |
| 7035 | " }\n" + |
| 7036 | " callin R0 otherK(R other) {\n" + |
| 7037 | " R0 r= base.otherK(other);\n" + |
| 7038 | " other.k();\n" + |
| 7039 | " return r;\n" + |
| 7040 | " }\n" + |
| 7041 | " otherK <- replace otherO;\n" + |
| 7042 | " }\n" + |
| 7043 | " public static void main(String[] args) {\n" + |
| 7044 | " within (new Team4140crc8()) {\n" + |
| 7045 | " new T4140crc8().otherO(new T4140crc8());\n" + |
| 7046 | " }\n" + |
| 7047 | " }\n" + |
| 7048 | "}\n" + |
| 7049 | " \n", |
| 7050 | "T4140crc8.java", |
| 7051 | "\n" + |
| 7052 | "public class T4140crc8 {\n" + |
| 7053 | " public void o() {\n" + |
| 7054 | " System.out.print(\"O\");\n" + |
| 7055 | " }\n" + |
| 7056 | " public T4140crc8 otherO(T4140crc8 other) {\n" + |
| 7057 | " other.o();\n" + |
| 7058 | " return other;\n" + |
| 7059 | " }\n" + |
| 7060 | "}\n" + |
| 7061 | " \n" |
| 7062 | }, |
| 7063 | "4.4(b)"); |
| 7064 | } |
| 7065 | |
| 7066 | // two different base methods have return types that are compatible to the bound of a type parameter |
| 7067 | // 4.1.40-otjld-callin-replace-compatibility-9 |
| 7068 | public void test4140_callinReplaceCompatibility9() { |
| 7069 | |
| 7070 | runConformTest( |
| 7071 | new String[] { |
| 7072 | "Team4140crc9.java", |
| 7073 | "\n" + |
| 7074 | "public team class Team4140crc9 {\n" + |
| 7075 | " protected class R playedBy T4140crc9 {\n" + |
| 7076 | " callin <T extends Object> T zork() {\n" + |
| 7077 | " T o= base.zork();\n" + |
| 7078 | " System.out.print(o.toString());\n" + |
| 7079 | " return o;\n" + |
| 7080 | " }\n" + |
| 7081 | " //zork <- replace foo, bar;\n" + |
| 7082 | " <T extends Object> T zork() <- replace String foo(), Object bar();\n" + |
| 7083 | " }\n" + |
| 7084 | " public static void main(String[] args) {\n" + |
| 7085 | " new Team4140crc9().activate();\n" + |
| 7086 | " T4140crc9 b= new T4140crc9();\n" + |
| 7087 | " String s= b.foo();\n" + |
| 7088 | " System.out.print(s.toUpperCase());\n" + |
| 7089 | " System.out.print(b.bar());\n" + |
| 7090 | " }\n" + |
| 7091 | "}\n" + |
| 7092 | " \n", |
| 7093 | "T4140crc9.java", |
| 7094 | "\n" + |
| 7095 | "public team class T4140crc9 {\n" + |
| 7096 | " String foo () { return \"foo\"; }\n" + |
| 7097 | " Object bar () { return new Object() { public String toString() { return \"bar\"; } }; }\n" + |
| 7098 | "}\n" + |
| 7099 | " \n" |
| 7100 | }, |
| 7101 | "fooFOObarbar"); |
| 7102 | } |
| 7103 | |
| 7104 | // two different base methods have return types that are compatible to the bound of a type parameter -- signatureless binding |
| 7105 | // 4.1.40-otjld-callin-replace-compatibility-9s |
| 7106 | public void test4140_callinReplaceCompatibility9s() { |
| 7107 | |
| 7108 | runConformTest( |
| 7109 | new String[] { |
| 7110 | "Team4140crc9s.java", |
| 7111 | "\n" + |
| 7112 | "public team class Team4140crc9s {\n" + |
| 7113 | " protected class R playedBy T4140crc9s {\n" + |
| 7114 | " callin <T extends Object> T zork() {\n" + |
| 7115 | " T o= base.zork();\n" + |
| 7116 | " System.out.print(o.toString());\n" + |
| 7117 | " return o;\n" + |
| 7118 | " }\n" + |
| 7119 | " zork <- replace foo, bar;\n" + |
| 7120 | " }\n" + |
| 7121 | " public static void main(String[] args) {\n" + |
| 7122 | " new Team4140crc9s().activate();\n" + |
| 7123 | " T4140crc9s b= new T4140crc9s();\n" + |
| 7124 | " String s= b.foo();\n" + |
| 7125 | " System.out.print(s.toUpperCase());\n" + |
| 7126 | " System.out.print(b.bar());\n" + |
| 7127 | " }\n" + |
| 7128 | "}\n" + |
| 7129 | " \n", |
| 7130 | "T4140crc9s.java", |
| 7131 | "\n" + |
| 7132 | "public team class T4140crc9s {\n" + |
| 7133 | " String foo () { return \"foo\"; }\n" + |
| 7134 | " Object bar () { return new Object() { public String toString() { return \"bar\"; } }; }\n" + |
| 7135 | "}\n" + |
| 7136 | " \n" |
| 7137 | }, |
| 7138 | "fooFOObarbar"); |
| 7139 | } |
| 7140 | |
| 7141 | // two different base methods have parameter types that are compatible to the bound of a type parameter |
| 7142 | // 4.1.40-otjld-callin-replace-compatibility-10 |
| 7143 | public void test4140_callinReplaceCompatibility10() { |
| 7144 | |
| 7145 | runConformTest( |
| 7146 | new String[] { |
| 7147 | "Team4140crc10.java", |
| 7148 | "\n" + |
| 7149 | "public team class Team4140crc10 {\n" + |
| 7150 | " protected class R playedBy T4140crc10 {\n" + |
| 7151 | " callin <T extends T4140crc10> void fred(T o) {\n" + |
| 7152 | " o.fub();\n" + |
| 7153 | " base.fred(o);\n" + |
| 7154 | " }\n" + |
| 7155 | " <T extends T4140crc10> void fred(T o) <- replace void process(T4140crc10 o), void process2(T4140crc10.T4140crc10_2 o);\n" + |
| 7156 | " }\n" + |
| 7157 | " public static void main(String[] args) {\n" + |
| 7158 | " new Team4140crc10().activate();\n" + |
| 7159 | " T4140crc10 b= new T4140crc10();\n" + |
| 7160 | " b.process(b);\n" + |
| 7161 | " b.process2(new T4140crc10.T4140crc10_2());\n" + |
| 7162 | " }\n" + |
| 7163 | "}\n" + |
| 7164 | " \n", |
| 7165 | "T4140crc10.java", |
| 7166 | "\n" + |
| 7167 | "public class T4140crc10 {\n" + |
| 7168 | " static class T4140crc10_2 extends T4140crc10 {\n" + |
| 7169 | " void zork() { System.out.print(\"zork\"); }\n" + |
| 7170 | " }\n" + |
| 7171 | " public String toString() { return \"T4140crc10\"; }\n" + |
| 7172 | " void fub() { System.out.print(\"fub\"); }\n" + |
| 7173 | " void process(T4140crc10 o) { System.out.print(o); }\n" + |
| 7174 | " void process2(T4140crc10_2 o) { o.zork(); }\n" + |
| 7175 | "}\n" + |
| 7176 | " \n" |
| 7177 | }, |
| 7178 | "fubT4140crc10fubzork"); |
| 7179 | } |
| 7180 | |
| 7181 | // two different base methods have parameter types that are compatible to the bound of a type parameter -- signatureless binding |
| 7182 | // 4.1.40-otjld-callin-replace-compatibility-10s |
| 7183 | public void test4140_callinReplaceCompatibility10s() { |
| 7184 | |
| 7185 | runConformTest( |
| 7186 | new String[] { |
| 7187 | "Team4140crc10s.java", |
| 7188 | "\n" + |
| 7189 | "public team class Team4140crc10s {\n" + |
| 7190 | " protected class R playedBy T4140crc10s {\n" + |
| 7191 | " callin <T extends T4140crc10s> void fred(T o) {\n" + |
| 7192 | " o.fub();\n" + |
| 7193 | " base.fred(o);\n" + |
| 7194 | " }\n" + |
| 7195 | " fred <- replace process, process2;\n" + |
| 7196 | " }\n" + |
| 7197 | " public static void main(String[] args) {\n" + |
| 7198 | " new Team4140crc10s().activate();\n" + |
| 7199 | " T4140crc10s b= new T4140crc10s();\n" + |
| 7200 | " b.process(b);\n" + |
| 7201 | " b.process2(new T4140crc10s.T4140crc10s_2());\n" + |
| 7202 | " }\n" + |
| 7203 | "}\n" + |
| 7204 | " \n", |
| 7205 | "T4140crc10s.java", |
| 7206 | "\n" + |
| 7207 | "public class T4140crc10s {\n" + |
| 7208 | " static class T4140crc10s_2 extends T4140crc10s {\n" + |
| 7209 | " void zork() { System.out.print(\"zork\"); }\n" + |
| 7210 | " }\n" + |
| 7211 | " public String toString() { return \"T4140crc10s\"; }\n" + |
| 7212 | " void fub() { System.out.print(\"fub\"); }\n" + |
| 7213 | " void process(T4140crc10s o) { System.out.print(o); }\n" + |
| 7214 | " void process2(T4140crc10s_2 o) { o.zork(); }\n" + |
| 7215 | "}\n" + |
| 7216 | " \n" |
| 7217 | }, |
| 7218 | "fubT4140crc10sfubzork"); |
| 7219 | } |
| 7220 | |
| 7221 | // a base method has parameter types that are compatible to the bound of a type parameter, 2 params, with mapping (swap) |
| 7222 | // 4.1.40-otjld-callin-replace-compatibility-11 |
| 7223 | public void test4140_callinReplaceCompatibility11() { |
| 7224 | |
| 7225 | runConformTest( |
| 7226 | new String[] { |
| 7227 | "Team4140crc11.java", |
| 7228 | "\n" + |
| 7229 | "public team class Team4140crc11 {\n" + |
| 7230 | " protected class R playedBy T4140crc11_2 {\n" + |
| 7231 | " callin <T1 extends T4140crc11_1, T2 extends T4140crc11_2> void fred(T1 o1, T2 o2) {\n" + |
| 7232 | " o1.fub1();\n" + |
| 7233 | " o2.fub2();\n" + |
| 7234 | " base.fred(o1, o2);\n" + |
| 7235 | " }\n" + |
| 7236 | " <T1 extends T4140crc11_1, T2 extends T4140crc11_2> void fred(T1 o1, T2 o2) <- replace void process(T4140crc11_2 b2, T4140crc11_1.Sub1 b1)\n" + |
| 7237 | " with {\n" + |
| 7238 | " o1 <- b1,\n" + |
| 7239 | " o2 <- b2\n" + |
| 7240 | " }\n" + |
| 7241 | " }\n" + |
| 7242 | " public static void main(String[] args) {\n" + |
| 7243 | " new Team4140crc11().activate();\n" + |
| 7244 | " T4140crc11_2 b= new T4140crc11_2.Sub2();\n" + |
| 7245 | " b.process(b, new T4140crc11_1.Sub1());\n" + |
| 7246 | " }\n" + |
| 7247 | "}\n" + |
| 7248 | " \n", |
| 7249 | "T4140crc11_1.java", |
| 7250 | "\n" + |
| 7251 | "public class T4140crc11_1 {\n" + |
| 7252 | " static class Sub1 extends T4140crc11_1 {\n" + |
| 7253 | " void zork1() { System.out.print(\"zork1\"); }\n" + |
| 7254 | " }\n" + |
| 7255 | " public String toString() { return \"T4140crc11_1\"; }\n" + |
| 7256 | " void fub1() { System.out.print(\"fub1\"); }\n" + |
| 7257 | "}\n" + |
| 7258 | " \n", |
| 7259 | "T4140crc11_2.java", |
| 7260 | "\n" + |
| 7261 | "public class T4140crc11_2 {\n" + |
| 7262 | " static class Sub2 extends T4140crc11_2 {\n" + |
| 7263 | " public String toString() { return \"Sub2\"; }\n" + |
| 7264 | " }\n" + |
| 7265 | " public String toString() { return \"T4140crc11_2\"; }\n" + |
| 7266 | " void fub2() { System.out.print(\"fub2\"); }\n" + |
| 7267 | " void process(T4140crc11_2 b2, T4140crc11_1.Sub1 b1) {\n" + |
| 7268 | " System.out.print(b2);\n" + |
| 7269 | " b1.zork1();\n" + |
| 7270 | " }\n" + |
| 7271 | "}\n" + |
| 7272 | " \n" |
| 7273 | }, |
| 7274 | "fub1fub2Sub2zork1"); |
| 7275 | } |
| 7276 | |
| 7277 | // a base method has parameter types that are compatible to the bound of a type parameter, 2 params, with partial mapping |
| 7278 | // 4.1.40-otjld-callin-replace-compatibility-12 |
| 7279 | public void test4140_callinReplaceCompatibility12() { |
| 7280 | |
| 7281 | runConformTest( |
| 7282 | new String[] { |
| 7283 | "Team4140crc12.java", |
| 7284 | "\n" + |
| 7285 | "public team class Team4140crc12 {\n" + |
| 7286 | " protected class R playedBy T4140crc12_2 {\n" + |
| 7287 | " callin <T1 extends T4140crc12_1> void fred(T1 o1) {\n" + |
| 7288 | " o1.fub1();\n" + |
| 7289 | " base.fred(o1);\n" + |
| 7290 | " }\n" + |
| 7291 | " <T1 extends T4140crc12_1> void fred(T1 o1) <- replace void process(T4140crc12_2 b2, T4140crc12_1.Sub1 b1)\n" + |
| 7292 | " with {\n" + |
| 7293 | " o1 <- b1\n" + |
| 7294 | " }\n" + |
| 7295 | " }\n" + |
| 7296 | " public static void main(String[] args) {\n" + |
| 7297 | " new Team4140crc12().activate();\n" + |
| 7298 | " T4140crc12_2 b= new T4140crc12_2.Sub2();\n" + |
| 7299 | " b.process(b, new T4140crc12_1.Sub1());\n" + |
| 7300 | " }\n" + |
| 7301 | "}\n" + |
| 7302 | " \n", |
| 7303 | "T4140crc12_1.java", |
| 7304 | "\n" + |
| 7305 | "public class T4140crc12_1 {\n" + |
| 7306 | " static class Sub1 extends T4140crc12_1 {\n" + |
| 7307 | " void zork1() { System.out.print(\"zork1\"); }\n" + |
| 7308 | " }\n" + |
| 7309 | " public String toString() { return \"T4140crc12_1\"; }\n" + |
| 7310 | " void fub1() { System.out.print(\"fub1\"); }\n" + |
| 7311 | "}\n" + |
| 7312 | " \n", |
| 7313 | "T4140crc12_2.java", |
| 7314 | "\n" + |
| 7315 | "public class T4140crc12_2 {\n" + |
| 7316 | " static class Sub2 extends T4140crc12_2 {\n" + |
| 7317 | " public String toString() { return \"Sub2\"; }\n" + |
| 7318 | " }\n" + |
| 7319 | " public String toString() { return \"T4140crc12_2\"; }\n" + |
| 7320 | " void fub2() { System.out.print(\"fub2\"); }\n" + |
| 7321 | " void process(T4140crc12_2 b2, T4140crc12_1.Sub1 b1) {\n" + |
| 7322 | " System.out.print(b2);\n" + |
| 7323 | " b1.zork1();\n" + |
| 7324 | " }\n" + |
| 7325 | "}\n" + |
| 7326 | " \n" |
| 7327 | }, |
| 7328 | "fub1Sub2zork1"); |
| 7329 | } |
| 7330 | |
| 7331 | // a role method uses the same type parameter twice - not used for covariant return |
| 7332 | // 4.1.40-otjld-callin-replace-compatibility-13 |
| 7333 | public void test4140_callinReplaceCompatibility13() { |
| 7334 | runConformTest( |
| 7335 | new String[] { |
| 7336 | "Team4140crc13.java", |
| 7337 | "\n" + |
| 7338 | "public team class Team4140crc13 {\n" + |
| 7339 | " protected class R {\n" + |
| 7340 | " callin <T> void ci (T a1, T a2) {\n" + |
| 7341 | " base.ci(a1, a2);\n" + |
| 7342 | " }\n" + |
| 7343 | " }\n" + |
| 7344 | "}\n" + |
| 7345 | " \n" |
| 7346 | }); |
| 7347 | } |
| 7348 | |
| 7349 | // a role method uses the same type parameter twice - trying to capture covariant return |
| 7350 | // 4.1.40-otjld-callin-replace-compatibility-14 |
| 7351 | public void test4140_callinReplaceCompatibility14() { |
| 7352 | runNegativeTestMatching( |
| 7353 | new String[] { |
| 7354 | "Team4140crc14.java", |
| 7355 | "\n" + |
| 7356 | "public team class Team4140crc14 {\n" + |
| 7357 | " protected class R playedBy T4140crc14 {\n" + |
| 7358 | " callin <T> T ci (Object a1, T a2) {\n" + |
| 7359 | " return base.ci(a1, a2);\n" + |
| 7360 | " }\n" + |
| 7361 | " <T> T ci(Object a1, T a2) <- replace Number+ bm(Object a1, Number a2);\n" + |
| 7362 | " }\n" + |
| 7363 | "}\n" + |
| 7364 | " \n", |
| 7365 | "T4140crc14.java", |
| 7366 | "\n" + |
| 7367 | "public class T4140crc14 {\n" + |
| 7368 | " Number bm(Object a1, Number a2) { return null; }\n" + |
| 7369 | "}\n" + |
| 7370 | " \n" |
| 7371 | }, |
| 7372 | "4.10(a)"); |
| 7373 | } |
| 7374 | |
| 7375 | // a callin binds to method hashCode |
| 7376 | // 4.1.41-otjld-dangerous-callin-binding-1 |
| 7377 | public void test4141_dangerousCallinBinding1() { |
| 7378 | runTestExpectingWarnings( |
| 7379 | new String[] { |
| 7380 | "T4141dcb1.java", |
| 7381 | "\n" + |
| 7382 | "public class T4141dcb1 {}\n" + |
| 7383 | " \n", |
| 7384 | "Team4141dcb1.java", |
| 7385 | "\n" + |
| 7386 | "public team class Team4141dcb1 {\n" + |
| 7387 | " protected class R playedBy T4141dcb1 {\n" + |
| 7388 | " @SuppressWarnings(\"basecall\")\n" + |
| 7389 | " callin int fourtytwo () { return 42; }\n" + |
| 7390 | " fourtytwo <- replace hashCode;\n" + |
| 7391 | " }\n" + |
| 7392 | "}\n" + |
| 7393 | " \n" |
| 7394 | }, |
| 7395 | "----------\n" + |
| 7396 | "1. WARNING in Team4141dcb1.java (at line 6)\n" + |
| 7397 | " fourtytwo <- replace hashCode;\n" + |
| 7398 | " ^^^^^^^^\n" + |
| 7399 | "Dangerous callin binding: hashCode() is used internally during lifting, which could create infinite recursion.\n" + |
| 7400 | "----------\n"); |
| 7401 | } |
| 7402 | |
| 7403 | // a callin binds to method equals - signature included, after callin |
| 7404 | // 4.1.41-otjld-dangerous-callin-binding-2 |
| 7405 | public void test4141_dangerousCallinBinding2() { |
| 7406 | runTestExpectingWarnings( |
| 7407 | new String[] { |
| 7408 | "T4141dcb2.java", |
| 7409 | "\n" + |
| 7410 | "public class T4141dcb2 {}\n" + |
| 7411 | " \n", |
| 7412 | "Team4141dcb2.java", |
| 7413 | "\n" + |
| 7414 | "public team class Team4141dcb2 {\n" + |
| 7415 | " protected class R playedBy T4141dcb2 {\n" + |
| 7416 | " void nothing() { }\n" + |
| 7417 | " void nothing() <- after boolean equals(Object other);\n" + |
| 7418 | " }\n" + |
| 7419 | "}\n" + |
| 7420 | " \n" |
| 7421 | }, |
| 7422 | "----------\n" + |
| 7423 | "1. WARNING in Team4141dcb2.java (at line 5)\n" + |
| 7424 | " void nothing() <- after boolean equals(Object other);\n" + |
| 7425 | " ^^^^^^\n" + |
Stephan Herrmann | 9a6c154 | 2012-01-29 20:40:53 +0100 | [diff] [blame] | 7426 | "Dangerous callin binding: equals(Object) is used internally during lifting, which could create infinite recursion.\n" + |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 7427 | "----------\n"); |
| 7428 | } |
| 7429 | |
| 7430 | // a callin binds to method equals - warning suppressed |
| 7431 | // 4.1.41-otjld-dangerous-callin-binding-3 |
| 7432 | public void test4141_dangerousCallinBinding3() { |
| 7433 | |
| 7434 | runConformTest( |
| 7435 | new String[] { |
| 7436 | "Team4141dcb3.java", |
| 7437 | "\n" + |
| 7438 | "public team class Team4141dcb3 {\n" + |
| 7439 | " protected class R playedBy T4141dcb3 {\n" + |
| 7440 | " @SuppressWarnings(\"basecall\")\n" + |
| 7441 | " callin boolean always() { return true; }\n" + |
| 7442 | " @SuppressWarnings(\"dangerouscallin\")\n" + |
| 7443 | " boolean always() <- replace boolean equals(Object other)\n" + |
| 7444 | " base when (!isExecutingCallin());\n" + |
| 7445 | " }\n" + |
| 7446 | " public static void main(String[] args) {\n" + |
| 7447 | " new Team4141dcb3().activate();\n" + |
| 7448 | " System.out.print(new T4141dcb3().equals(new T4141dcb3()));\n" + |
| 7449 | " }\n" + |
| 7450 | "}\n" + |
| 7451 | " \n", |
| 7452 | "T4141dcb3.java", |
| 7453 | "\n" + |
| 7454 | "public class T4141dcb3 {}\n" + |
| 7455 | " \n" |
| 7456 | }, |
| 7457 | "true"); |
| 7458 | } |
| 7459 | |
| 7460 | // a callin binding is inherited, read from binary - witness for NPE in SingleValueAttribute.evaluate reported by Marco |
| 7461 | // 4.1.42-otjld-inheritance-of-callin-binding-1 |
| 7462 | public void test4142_inheritanceOfCallinBinding1() { |
| 7463 | |
| 7464 | runConformTest( |
| 7465 | new String[] { |
| 7466 | "T4142iocb1Main.java", |
| 7467 | "\n" + |
| 7468 | "public class T4142iocb1Main {\n" + |
| 7469 | " public static void main(String[] args) {\n" + |
| 7470 | " final Team4142iocb1_2 t = new Team4142iocb1_2();\n" + |
| 7471 | " t.activate();\n" + |
| 7472 | " new T4142iocb1().foo();\n" + |
| 7473 | " R<@t> r = t.getR(); // force reading class R.\n" + |
| 7474 | " }\n" + |
| 7475 | "}\n" + |
| 7476 | " \n", |
| 7477 | "T4142iocb1.java", |
| 7478 | "\n" + |
| 7479 | "public class T4142iocb1 {\n" + |
| 7480 | " void foo() {}\n" + |
| 7481 | "}\n" + |
| 7482 | " \n", |
| 7483 | "Team4142iocb1_1.java", |
| 7484 | "\n" + |
| 7485 | "public team class Team4142iocb1_1 {\n" + |
| 7486 | " R r;\n" + |
| 7487 | " public class R playedBy T4142iocb1 {\n" + |
| 7488 | " private void test() {\n" + |
| 7489 | " System.out.print(\"OK\");\n" + |
| 7490 | " r=this;\n" + |
| 7491 | " }\n" + |
| 7492 | " test <- after foo; // callin to private role method requires copy-inh of wrapper\n" + |
| 7493 | " }\n" + |
| 7494 | "}\n" + |
| 7495 | " \n", |
| 7496 | "Team4142iocb1_2.java", |
| 7497 | "\n" + |
| 7498 | "public team class Team4142iocb1_2 extends Team4142iocb1_1 {\n" + |
| 7499 | " public R getR() { return this.r; }\n" + |
| 7500 | "}\n" + |
| 7501 | " \n" |
| 7502 | }, |
| 7503 | "OK"); |
| 7504 | } |
| 7505 | |
| 7506 | // a bound base method is deprecated |
| 7507 | // 4.1.43-otjld-callin-to-deprecated-1 |
| 7508 | public void test4143_callinToDeprecated1() { |
| 7509 | runNegativeTestMatching( |
| 7510 | new String[] { |
| 7511 | "Team4143ctd1.java", |
| 7512 | "\n" + |
| 7513 | "public team class Team4143ctd1 {\n" + |
| 7514 | " protected class R playedBy T4143ctd1 {\n" + |
| 7515 | " void rm() {}\n" + |
| 7516 | " rm <- after test;\n" + |
| 7517 | " }\n" + |
| 7518 | "}\n" + |
| 7519 | " \n", |
| 7520 | "T4143ctd1.java", |
| 7521 | "\n" + |
| 7522 | "public class T4143ctd1 {\n" + |
| 7523 | " /** @deprecated don't use. */\n" + |
| 7524 | " @Deprecated\n" + |
| 7525 | " void test() {}\n" + |
| 7526 | "}\n" + |
| 7527 | " \n" |
| 7528 | }, |
| 7529 | "----------\n" + |
| 7530 | "1. ERROR in Team4143ctd1.java (at line 5)\n" + |
| 7531 | " rm <- after test;\n" + |
| 7532 | " ^^^^\n" + |
| 7533 | "Bound base method test() is deprecated.\n" + |
| 7534 | "----------\n"); |
| 7535 | } |
| 7536 | |
| 7537 | // a bound base method is deprecated - configured to warning |
| 7538 | // 4.1.43-otjld-callin-to-deprecated-1w |
| 7539 | public void test4143_callinToDeprecated1w() { |
| 7540 | Map customOptions = getCompilerOptions(); |
| 7541 | customOptions.put(CompilerOptions.OPTION_ReportAdaptingDeprecated, CompilerOptions.WARNING); |
| 7542 | runTestExpectingWarnings( |
| 7543 | new String[] { |
| 7544 | "T4143ctd1w.java", |
| 7545 | "\n" + |
| 7546 | "public class T4143ctd1w {\n" + |
| 7547 | " /** @deprecated don't use. */\n" + |
| 7548 | " @Deprecated\n" + |
| 7549 | " void test() {}\n" + |
| 7550 | "}\n" + |
| 7551 | " \n", |
| 7552 | "Team4143ctd1w.java", |
| 7553 | "\n" + |
| 7554 | "public team class Team4143ctd1w {\n" + |
| 7555 | " protected class R playedBy T4143ctd1w {\n" + |
| 7556 | " void rm() {}\n" + |
| 7557 | " rm <- after test;\n" + |
| 7558 | " }\n" + |
| 7559 | "}\n" + |
| 7560 | " \n" |
| 7561 | }, |
| 7562 | "----------\n" + |
| 7563 | "1. WARNING in Team4143ctd1w.java (at line 5)\n" + |
| 7564 | " rm <- after test;\n" + |
| 7565 | " ^^^^\n" + |
| 7566 | "Bound base method test() is deprecated.\n" + |
| 7567 | "----------\n", |
| 7568 | customOptions); |
| 7569 | } |
| 7570 | |
| 7571 | // an after callin binding refers to a team method instead of a role method |
| 7572 | // 4.1.43-otjld-callin-to-team-method-1 |
| 7573 | public void test4143_callinToTeamMethod1() { |
| 7574 | |
| 7575 | runConformTest( |
| 7576 | new String[] { |
| 7577 | "Team4143cttm1.java", |
| 7578 | "\n" + |
| 7579 | "public team class Team4143cttm1 {\n" + |
| 7580 | " void k(String s) {\n" + |
| 7581 | " System.out.print(s);\n" + |
| 7582 | " }\n" + |
| 7583 | " protected class R playedBy T4143cttm1 {\n" + |
| 7584 | " void k(String s) <- after void test()\n" + |
| 7585 | " with { s <- \"K\" }\n" + |
| 7586 | " }\n" + |
| 7587 | " public static void main(String[] args) {\n" + |
| 7588 | " new Team4143cttm1().activate();\n" + |
| 7589 | " new T4143cttm1().test();\n" + |
| 7590 | " }\n" + |
| 7591 | "}\n" + |
| 7592 | " \n", |
| 7593 | "T4143cttm1.java", |
| 7594 | "\n" + |
| 7595 | "public class T4143cttm1 {\n" + |
| 7596 | " public void test() {\n" + |
| 7597 | " System.out.print(\"O\");\n" + |
| 7598 | " }\n" + |
| 7599 | "}\n" + |
| 7600 | " \n" |
| 7601 | }, |
| 7602 | "OK"); |
| 7603 | } |
| 7604 | |
| 7605 | // an after callin binding refers to an inherited team method instead of a role method |
| 7606 | // 4.1.43-otjld-callin-to-team-method-2 |
| 7607 | public void test4143_callinToTeamMethod2() { |
| 7608 | |
| 7609 | runConformTest( |
| 7610 | new String[] { |
| 7611 | "Team4143cttm2_2.java", |
| 7612 | "\n" + |
| 7613 | "public team class Team4143cttm2_2 extends Team4143cttm2_1 {\n" + |
| 7614 | " protected class R playedBy T4143cttm2 {\n" + |
| 7615 | " void k(String s) <- after void test()\n" + |
| 7616 | " with { s <- \"K\" }\n" + |
| 7617 | " }\n" + |
| 7618 | " public static void main(String[] args) {\n" + |
| 7619 | " new Team4143cttm2_2().activate();\n" + |
| 7620 | " new T4143cttm2().test();\n" + |
| 7621 | " }\n" + |
| 7622 | "}\n" + |
| 7623 | " \n", |
| 7624 | "T4143cttm2.java", |
| 7625 | "\n" + |
| 7626 | "public class T4143cttm2 {\n" + |
| 7627 | " public void test() {\n" + |
| 7628 | " System.out.print(\"O\");\n" + |
| 7629 | " }\n" + |
| 7630 | "}\n" + |
| 7631 | " \n", |
| 7632 | "Team4143cttm2_1.java", |
| 7633 | "\n" + |
| 7634 | "public team class Team4143cttm2_1 {\n" + |
| 7635 | " void k(String s) {\n" + |
| 7636 | " System.out.print(s);\n" + |
| 7637 | " }\n" + |
| 7638 | "}\n" + |
| 7639 | " \n" |
| 7640 | }, |
| 7641 | "OK"); |
| 7642 | } |
| 7643 | |
| 7644 | // a short after callin binding refers to a team method instead of a role method |
| 7645 | // 4.1.43-otjld-callin-to-team-method-3 |
| 7646 | public void test4143_callinToTeamMethod3() { |
| 7647 | Map customOptions = getCompilerOptions(); |
| 7648 | customOptions.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.ENABLED); |
| 7649 | customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.WARNING); |
| 7650 | |
| 7651 | runConformTest( |
| 7652 | new String[] { |
| 7653 | "Team4143cttm3.java", |
| 7654 | "\n" + |
| 7655 | "/**\n" + |
| 7656 | " * @role R\n" + |
| 7657 | " */\n" + |
| 7658 | "public team class Team4143cttm3 {\n" + |
Stephan Herrmann | de4a080 | 2011-01-04 21:06:39 +0000 | [diff] [blame] | 7659 | " private void k(String s) {\n" + // extra difficulty: team method is private |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 7660 | " System.out.print(s);\n" + |
| 7661 | " }\n" + |
| 7662 | " public static void main(String[] args) {\n" + |
| 7663 | " new Team4143cttm3().activate();\n" + |
| 7664 | " new T4143cttm3().test(\"OK\");\n" + |
| 7665 | " }\n" + |
| 7666 | "}\n" + |
| 7667 | " \n", |
| 7668 | "T4143cttm3.java", |
| 7669 | "\n" + |
| 7670 | "public class T4143cttm3 {\n" + |
| 7671 | " public void test(String s) {\n" + |
| 7672 | " // nop\n" + |
| 7673 | " }\n" + |
| 7674 | "}\n" + |
| 7675 | " \n", |
| 7676 | "Team4143cttm3/R.java", |
| 7677 | "\n" + |
| 7678 | "team package Team4143cttm3;\n" + |
| 7679 | "protected class R playedBy T4143cttm3 {\n" + |
| 7680 | " k <- after test;\n" + |
| 7681 | "}\n" + |
| 7682 | " \n" |
| 7683 | }, |
| 7684 | "OK", |
| 7685 | null/*classLibraries*/, |
| 7686 | true/*shouldFlushOutputDirectory*/, |
| 7687 | null/*vmArguments*/, |
| 7688 | customOptions, |
| 7689 | null/*no custom requestor*/); |
| 7690 | } |
Stephan Herrmann | 273982d | 2013-01-10 22:22:03 +0100 | [diff] [blame] | 7691 | |
| 7692 | // an after callin binding refers to a package-private method of a super team |
| 7693 | // https://bugs.eclipse.org/397867 - [compiler] illegal access to invisible method via callin binding not detected |
| 7694 | public void test4143_callinToTeamMethod4() { |
| 7695 | runNegativeTest( |
| 7696 | new String[] { |
| 7697 | "p2/Team4143cttm4_2.java", |
| 7698 | "package p2;\n" + |
| 7699 | "import base p0.T4143cttm4;\n" + |
| 7700 | "public team class Team4143cttm4_2 extends p1.Team4143cttm4_1 {\n" + |
| 7701 | " protected class R playedBy T4143cttm4 {\n" + |
| 7702 | " void k(String s) <- after void test()\n" + |
| 7703 | " with { s <- \"K\" }\n" + |
| 7704 | " }\n" + |
| 7705 | "}\n", |
| 7706 | "p1/Team4143cttm4_1.java", |
| 7707 | "package p1;\n" + |
| 7708 | "public team class Team4143cttm4_1 {\n" + |
| 7709 | " void k(String s) {\n" + |
| 7710 | " System.out.print(s);\n" + |
| 7711 | " }\n" + |
| 7712 | "}\n", |
| 7713 | "p0/T4143cttm4.java", |
| 7714 | "package p0;\n" + |
| 7715 | "public class T4143cttm4 {\n" + |
| 7716 | " public void test() {\n" + |
| 7717 | " System.out.print(\"O\");\n" + |
| 7718 | " }\n" + |
| 7719 | "}\n" |
| 7720 | }, |
| 7721 | "----------\n" + |
| 7722 | "1. ERROR in p2\\Team4143cttm4_2.java (at line 5)\n" + |
| 7723 | " void k(String s) <- after void test()\n" + |
| 7724 | " ^\n" + |
| 7725 | "The method k(String) from the type Team4143cttm4_1 is not visible\n" + |
| 7726 | "----------\n"); |
| 7727 | } |
| 7728 | |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 7729 | // implicitly inherited role method requires weakening |
| 7730 | public void test4144_callinToInherited1() { |
| 7731 | runConformTest( |
| 7732 | new String[] { |
| 7733 | "Team4144cti1_2.java", |
| 7734 | "public team class Team4144cti1_2 extends Team4144cti1_1 {\n" + |
| 7735 | " @Override\n" + |
| 7736 | " protected class R1 playedBy T4144cti1_1 {\n" + |
| 7737 | " test <- after test\n;" + |
| 7738 | " }\n" + |
| 7739 | " @Override\n" + |
| 7740 | " protected class R2 playedBy T4144cti1_2 {}\n" + |
| 7741 | " public static void main(String... args) {\n" + |
| 7742 | " new Team4144cti1_2().activate();\n" + |
| 7743 | " new T4144cti1_1().test(new T4144cti1_2());\n" + |
| 7744 | " }\n" + |
| 7745 | "}\n", |
| 7746 | "Team4144cti1_1.java", |
| 7747 | "public team class Team4144cti1_1 {\n" + |
| 7748 | " protected class R1 {\n" + |
| 7749 | " void test(R2 other) {\n" + |
| 7750 | " other.print();\n" + |
| 7751 | " }\n" + |
| 7752 | " }\n" + |
| 7753 | " protected class R2 {\n" + |
| 7754 | " protected void print() {\n" + |
| 7755 | " System.out.print(\"K\");\n" + |
| 7756 | " }\n" + |
| 7757 | " }\n" + |
| 7758 | "}\n", |
| 7759 | "T4144cti1_1.java", |
| 7760 | "public class T4144cti1_1 {\n" + |
| 7761 | " public void test(T4144cti1_2 other) {\n" + |
| 7762 | " System.out.print(\"O\");\n" + |
| 7763 | " }\n" + |
| 7764 | "}\n", |
| 7765 | "T4144cti1_2.java", |
| 7766 | "public class T4144cti1_2 {}\n" |
| 7767 | }, |
| 7768 | "OK"); |
| 7769 | } |
| 7770 | |
| 7771 | // Bug 318309 - [compiler] warnings re unused exceptions from generated code |
| 7772 | // a role method does not declare the expection that it base method may throw |
| 7773 | public void test4145_baseMethodWithException1() { |
| 7774 | Map customOptions = getCompilerOptions(); |
| 7775 | customOptions.put(CompilerOptions.OPTION_ReportUnusedDeclaredThrownException, CompilerOptions.ERROR); |
| 7776 | customOptions.put(CompilerOptions.OPTION_ReportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable, CompilerOptions.DISABLED); |
| 7777 | |
| 7778 | runConformTest( |
| 7779 | new String[] { |
| 7780 | "Team4145bmwe1.java", |
| 7781 | "public team class Team4145bmwe1 {\n" + |
| 7782 | " protected class R playedBy T4145bmwe1 {\n" + |
| 7783 | " @SuppressWarnings(\"basecall\")\n" + |
| 7784 | " callin void foo() {\n" + |
| 7785 | " System.out.print(\"OK\");\n" + |
| 7786 | " }\n" + |
| 7787 | " foo <- replace bar;\n" + |
| 7788 | " }\n" + |
| 7789 | " public static void main(String... args) throws Exception {\n" + |
| 7790 | " new Team4145bmwe1().activate();\n" + |
| 7791 | " new T4145bmwe1().bar();\n" + |
| 7792 | " }\n" + |
| 7793 | "}\n", |
| 7794 | "T4145bmwe1.java", |
| 7795 | "public class T4145bmwe1 {\n" + |
| 7796 | " void bar() throws Exception { throw new Exception(\"Not Implemented\"); }\n" + |
| 7797 | "}\n" |
| 7798 | }, |
| 7799 | "OK", |
| 7800 | null/*classLibraries*/, |
| 7801 | true/*shouldFlushOutputDirectory*/, |
| 7802 | null/*vmArguments*/, |
| 7803 | customOptions, |
| 7804 | null/*no custom requestor*/); |
| 7805 | } |
Stephan Herrmann | 12a2074 | 2013-04-25 20:12:57 +0200 | [diff] [blame] | 7806 | |
| 7807 | public void test4146_callinToConstructor1() { |
| 7808 | runConformTest( |
| 7809 | new String[] { |
| 7810 | "Team4146ctc1.java", |
| 7811 | "public team class Team4146ctc1 {\n" + |
| 7812 | " protected class R playedBy T4146ctc1 {\n" + |
| 7813 | " void print() { System.out.print('K'); }\n" + |
| 7814 | " void print() <- after T4146ctc1();\n" + |
| 7815 | " }\n" + |
| 7816 | " public static void main(String... args) {\n" + |
| 7817 | " new Team4146ctc1().activate();\n" + |
| 7818 | " new T4146ctc1().test();\n" + |
| 7819 | " }\n" + |
| 7820 | "}\n", |
| 7821 | "T4146ctc1.java", |
| 7822 | "public class T4146ctc1 {\n" + |
| 7823 | " T4146ctc1() { System.out.print('O'); }\n" + |
| 7824 | " public void test() { System.out.print('!'); }\n" + |
| 7825 | "}\n" |
| 7826 | }, |
| 7827 | "OK!"); |
| 7828 | } |
| 7829 | |
| 7830 | // before-ctor callin is illegal |
| 7831 | public void test4146_callinToConstructor2() { |
| 7832 | runNegativeTest( |
| 7833 | new String[] { |
| 7834 | "Team4146ctc1.java", |
| 7835 | "public team class Team4146ctc1 {\n" + |
| 7836 | " protected class R playedBy T4146ctc1 {\n" + |
| 7837 | " void print() { System.out.print('K'); }\n" + |
| 7838 | " print <- before T4146ctc1;\n" + |
| 7839 | " }\n" + |
| 7840 | " public static void main(String... args) {\n" + |
| 7841 | " new Team4146ctc1().activate();\n" + |
| 7842 | " new T4146ctc1().test();\n" + |
| 7843 | " }\n" + |
| 7844 | "}\n", |
| 7845 | "T4146ctc1.java", |
| 7846 | "public class T4146ctc1 {\n" + |
| 7847 | " T4146ctc1() { System.out.print('O'); }\n" + |
| 7848 | " public void test() { System.out.print('!'); }\n" + |
| 7849 | "}\n" |
| 7850 | }, |
| 7851 | "----------\n" + |
| 7852 | "1. ERROR in Team4146ctc1.java (at line 4)\n" + |
| 7853 | " print <- before T4146ctc1;\n" + |
| 7854 | " ^^^^^^^^^\n" + |
| 7855 | "Callin binding to constructor \'T4146ctc1()\' must use the callin modifier \"after\" (OTJLD 4.1(h)). \n" + |
| 7856 | "----------\n"); |
| 7857 | } |
| 7858 | |
| 7859 | // passing ctor arguments into the callin |
| 7860 | public void test4146_callinToConstructor3() { |
| 7861 | runConformTest( |
| 7862 | new String[] { |
| 7863 | "Team4146ctc1.java", |
| 7864 | "public team class Team4146ctc1 {\n" + |
| 7865 | " protected class R playedBy T4146ctc1 {\n" + |
| 7866 | " void print(String prefix, int n) {\n" + |
| 7867 | " for (int i=0; i<n; i++)\n" + |
| 7868 | " System.out.print(prefix);\n" + |
| 7869 | " }" + |
| 7870 | " print <- after T4146ctc1;\n" + |
| 7871 | " }\n" + |
| 7872 | " public static void main(String... args) {\n" + |
| 7873 | " new Team4146ctc1().activate();\n" + |
| 7874 | " new T4146ctc1(\"_\", 3).test();\n" + |
| 7875 | " }\n" + |
| 7876 | "}\n", |
| 7877 | "T4146ctc1.java", |
| 7878 | "public class T4146ctc1 {\n" + |
| 7879 | " T4146ctc1(String prefix, int n) { System.out.print('O'); }\n" + |
| 7880 | " public void test() { System.out.print('!'); }\n" + |
| 7881 | "}\n" |
| 7882 | }, |
| 7883 | "O___!"); |
| 7884 | } |
| 7885 | |
| 7886 | // ctor with early return |
| 7887 | public void test4146_callinToConstructor4() { |
| 7888 | runConformTest( |
| 7889 | new String[] { |
| 7890 | "Team4146ctc1.java", |
| 7891 | "public team class Team4146ctc1 {\n" + |
| 7892 | " protected class R playedBy T4146ctc1 {\n" + |
| 7893 | " void print(String prefix, int n) {\n" + |
| 7894 | " for (int i=0; i<n; i++)\n" + |
| 7895 | " System.out.print(prefix);\n" + |
| 7896 | " }" + |
| 7897 | " print <- after T4146ctc1;\n" + |
| 7898 | " }\n" + |
| 7899 | " public static void main(String... args) {\n" + |
| 7900 | " new Team4146ctc1().activate();\n" + |
| 7901 | " new T4146ctc1(\"_\", 3).test();\n" + |
| 7902 | " }\n" + |
| 7903 | "}\n", |
| 7904 | "T4146ctc1.java", |
| 7905 | "public class T4146ctc1 {\n" + |
| 7906 | " T4146ctc1(String prefix, int n) {\n" + |
| 7907 | " if (n == 3) {\n" + |
| 7908 | " System.out.print('O');\n" + |
| 7909 | " return;\n" + |
| 7910 | " }\n" + |
| 7911 | " System.out.print(\"NotOK\");\n" + |
| 7912 | " }\n" + |
| 7913 | " public void test() { System.out.print('!'); }\n" + |
| 7914 | "}\n" |
| 7915 | }, |
| 7916 | "O___!"); |
| 7917 | } |
| 7918 | |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 7919 | // ==== from binding-of-abstract-and-concrete-methods: ==== |
| 7920 | |
| 7921 | |
| 7922 | // a callin binding binds to an abstract method though the team is not marked abstract |
| 7923 | // 7.2.4-otjld-callin-bound-abstract-method-1 |
| 7924 | public void test724_callinBoundAbstractMethod1() { |
| 7925 | runNegativeTestMatching( |
| 7926 | new String[] { |
| 7927 | "Team724cbam1.java", |
| 7928 | "\n" + |
| 7929 | "public team class Team724cbam1 {\n" + |
| 7930 | " public abstract class Role724cbam1 playedBy T724cbam1 {\n" + |
| 7931 | " abstract callin String test();\n" + |
| 7932 | " test <- replace toString;\n" + |
| 7933 | " }\n" + |
| 7934 | "}\n" + |
| 7935 | " \n", |
| 7936 | "T724cbam1.java", |
| 7937 | "\n" + |
| 7938 | "public class T724cbam1 {}\n" + |
| 7939 | " \n" |
| 7940 | }, |
| 7941 | "2.5(b)"); |
| 7942 | } |
| 7943 | |
| 7944 | // a callin binding binds to an abstract method though the team is not marked abstract |
| 7945 | // 7.2.4-otjld-callin-bound-abstract-method-2 |
| 7946 | public void test724_callinBoundAbstractMethod2() { |
Stephan Herrmann | 471273b | 2011-08-23 16:24:35 +0000 | [diff] [blame] | 7947 | runNegativeTest( |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 7948 | new String[] { |
| 7949 | "Team724cbam2_2.java", |
| 7950 | "\n" + |
| 7951 | "public team class Team724cbam2_2 extends Team724cbam2_1 {\n" + |
| 7952 | " @Override\n" + |
| 7953 | " public class Role724cbam2 playedBy T724cbam2 {\n" + |
| 7954 | " test <- replace toString;\n" + |
| 7955 | " }\n" + |
| 7956 | "}\n" + |
| 7957 | " \n", |
| 7958 | "T724cbam2.java", |
| 7959 | "\n" + |
| 7960 | "public class T724cbam2 {}\n" + |
| 7961 | " \n", |
| 7962 | "Team724cbam2_1.java", |
| 7963 | "\n" + |
| 7964 | "public abstract team class Team724cbam2_1 {\n" + |
| 7965 | " public abstract class Role724cbam2 {\n" + |
| 7966 | " abstract callin String test();\n" + |
| 7967 | " }\n" + |
| 7968 | "}\n" + |
| 7969 | " \n" |
| 7970 | }, |
| 7971 | "----------\n" + |
Stephan Herrmann | 471273b | 2011-08-23 16:24:35 +0000 | [diff] [blame] | 7972 | "1. ERROR in Team724cbam2_2.java (at line 4)\n" + |
| 7973 | " public class Role724cbam2 playedBy T724cbam2 {\n" + |
| 7974 | " ^^^^^^^^^^^^\n" + |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 7975 | "The abstract method test in type Role724cbam2 can only be defined by an abstract class\n" + |
Stephan Herrmann | d425912 | 2011-10-04 21:46:46 +0000 | [diff] [blame] | 7976 | "----------\n" + |
| 7977 | "2. ERROR in Team724cbam2_2.java (at line 4)\n" + |
| 7978 | " public class Role724cbam2 playedBy T724cbam2 {\n" + |
| 7979 | " ^^^^^^^^^^^^\n" + |
| 7980 | "The type Team724cbam2_2.Role724cbam2 must implement the inherited abstract method Team724cbam2_2.Role724cbam2.test()\n" + |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 7981 | "----------\n"); |
| 7982 | } |
| 7983 | |
| 7984 | // a callin binding binds to an abstract method where the explicit superclass has a concrete implementation, and the team is not marked abstract |
| 7985 | // 7.2.5-otjld-callin-bound-abstract-method-1 |
| 7986 | public void test725_callinBoundAbstractMethod1() { |
Stephan Herrmann | 471273b | 2011-08-23 16:24:35 +0000 | [diff] [blame] | 7987 | runNegativeTest( |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 7988 | new String[] { |
| 7989 | "Team725cbam1_2.java", |
| 7990 | "\n" + |
| 7991 | "public team class Team725cbam1_2 extends Team725cbam1_1 {\n" + |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 7992 | " public class Role725cbam1_1 playedBy T725cbam1 {\n" + |
| 7993 | " callin void test() {\n" + |
| 7994 | " base.test();\n" + |
| 7995 | " }\n" + |
| 7996 | " }\n" + |
| 7997 | "\n" + |
Stephan Herrmann | 471273b | 2011-08-23 16:24:35 +0000 | [diff] [blame] | 7998 | " @Override\n" + |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 7999 | " public class Role725cbam1_2 extends Role725cbam1_1 playedBy T725cbam1 {\n" + |
| 8000 | " test <- replace test;\n" + |
| 8001 | " }\n" + |
| 8002 | "}\n" + |
| 8003 | " \n", |
| 8004 | "T725cbam1.java", |
| 8005 | "\n" + |
| 8006 | "public class T725cbam1 {\n" + |
| 8007 | " public void test() {}\n" + |
| 8008 | "}\n" + |
| 8009 | " \n", |
| 8010 | "Team725cbam1_1.java", |
| 8011 | "\n" + |
| 8012 | "public abstract team class Team725cbam1_1 {\n" + |
| 8013 | " public abstract class Role725cbam1_2 {\n" + |
| 8014 | " abstract callin void test();\n" + |
| 8015 | " }\n" + |
| 8016 | "}\n" + |
| 8017 | " \n" |
| 8018 | }, |
| 8019 | "----------\n" + |
Stephan Herrmann | 471273b | 2011-08-23 16:24:35 +0000 | [diff] [blame] | 8020 | "1. ERROR in Team725cbam1_2.java (at line 10)\n" + |
| 8021 | " public class Role725cbam1_2 extends Role725cbam1_1 playedBy T725cbam1 {\n" + |
| 8022 | " ^^^^^^^^^^^^^^\n" + |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 8023 | "The abstract method test in type Role725cbam1_2 can only be defined by an abstract class\n" + |
Stephan Herrmann | d425912 | 2011-10-04 21:46:46 +0000 | [diff] [blame] | 8024 | "----------\n" + |
| 8025 | "2. ERROR in Team725cbam1_2.java (at line 10)\n" + |
| 8026 | " public class Role725cbam1_2 extends Role725cbam1_1 playedBy T725cbam1 {\n" + |
| 8027 | " ^^^^^^^^^^^^^^\n" + |
| 8028 | "The type Team725cbam1_2.Role725cbam1_2 must implement the inherited abstract method Team725cbam1_2.Role725cbam1_2.test()\n" + |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 8029 | "----------\n"); |
| 8030 | } |
| 8031 | |
| 8032 | // same structure as above but without abstractness - witness for incompatible return of inherited base call surrogate |
| 8033 | // 7.2.5-otjld-callin-bound-abstract-method-1a |
| 8034 | public void test725_callinBoundAbstractMethod1a() { |
| 8035 | runConformTest( |
| 8036 | new String[] { |
| 8037 | "T725cbam1a.java", |
| 8038 | "\n" + |
| 8039 | "public class T725cbam1a {\n" + |
| 8040 | " public void test() {}\n" + |
| 8041 | "}\n" + |
| 8042 | " \n", |
| 8043 | "Team725cbam1a_1.java", |
| 8044 | "\n" + |
| 8045 | "public team class Team725cbam1a_1 {\n" + |
| 8046 | " public class Role725cbam1a_2 {\n" + |
| 8047 | " callin void test() { base.test(); }\n" + |
| 8048 | " }\n" + |
| 8049 | "}\n" + |
| 8050 | " \n", |
| 8051 | "Team725cbam1a_2.java", |
| 8052 | "\n" + |
| 8053 | "public team class Team725cbam1a_2 extends Team725cbam1a_1 {\n" + |
| 8054 | " public class Role725cbam1a_1 playedBy T725cbam1a {\n" + |
| 8055 | " callin void test() {\n" + |
| 8056 | " base.test();\n" + |
| 8057 | " }\n" + |
| 8058 | " }\n" + |
| 8059 | "\n" + |
| 8060 | " public class Role725cbam1a_2 extends Role725cbam1a_1 playedBy T725cbam1a {\n" + |
| 8061 | " test <- replace test;\n" + |
| 8062 | " }\n" + |
| 8063 | "}\n" + |
| 8064 | " \n" |
| 8065 | }); |
| 8066 | } |
| 8067 | |
| 8068 | // a callin binding binds to an abstract method where the explicit superclass has a concrete implementation, and the team is not marked abstract |
| 8069 | // 7.2.5-otjld-callin-bound-abstract-method-2 |
| 8070 | public void test725_callinBoundAbstractMethod2() { |
| 8071 | runNegativeTestMatching( |
| 8072 | new String[] { |
| 8073 | "Team725cbam2_2.java", |
| 8074 | "\n" + |
| 8075 | "public team class Team725cbam2_2 extends Team725cbam2_1 {\n" + |
| 8076 | " @Override\n" + |
| 8077 | " public class Role725cbam2_2 extends Role725cbam2_1 {}\n" + |
| 8078 | "}\n" + |
| 8079 | " \n", |
| 8080 | "T725cbam2.java", |
| 8081 | "\n" + |
| 8082 | "public class T725cbam2 {\n" + |
| 8083 | " public void test() {}\n" + |
| 8084 | "}\n" + |
| 8085 | " \n", |
| 8086 | "Team725cbam2_1.java", |
| 8087 | "\n" + |
| 8088 | "public abstract team class Team725cbam2_1 {\n" + |
| 8089 | " public class Role725cbam2_1 playedBy T725cbam2 {\n" + |
| 8090 | " callin void test() {\n" + |
| 8091 | " base.test();\n" + |
| 8092 | " }\n" + |
| 8093 | " }\n" + |
| 8094 | "\n" + |
| 8095 | " public abstract class Role725cbam2_2 playedBy T725cbam2 {\n" + |
| 8096 | " abstract callin void test();\n" + |
| 8097 | " test <- replace test;\n" + |
| 8098 | " }\n" + |
| 8099 | "}\n" + |
| 8100 | " \n" |
| 8101 | }, |
| 8102 | "----------\n" + |
Stephan Herrmann | 471273b | 2011-08-23 16:24:35 +0000 | [diff] [blame] | 8103 | "1. ERROR in Team725cbam2_2.java (at line 4)\n" + |
| 8104 | " public class Role725cbam2_2 extends Role725cbam2_1 {}\n" + |
| 8105 | " ^^^^^^^^^^^^^^\n" + |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 8106 | "The abstract method test in type Role725cbam2_2 can only be defined by an abstract class\n" + |
| 8107 | "----------\n"); |
| 8108 | } |
Stephan Herrmann | 7aa4219 | 2011-05-10 23:29:37 +0000 | [diff] [blame] | 8109 | // Bug 337413 - [otjld][compiler] consider changing LiftingFailedException to a checked exception |
| 8110 | // need to declare LiftingFailedException but luckily the program still works :) |
| 8111 | public void test726_callinWithHiddenLiftingProblem1() { |
| 8112 | Map options = getCompilerOptions(); |
| 8113 | options.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED); |
| 8114 | options.put(CompilerOptions.OPTION_ReportUnsafeRoleInstantiation, CompilerOptions.IGNORE); // see new R2(b); |
| 8115 | runConformTest( |
| 8116 | new String[] { |
| 8117 | "Team726cwhlp1.java", |
| 8118 | "@SuppressWarnings(\"ambiguousbinding\")\n" + |
| 8119 | "public team class Team726cwhlp1 {\n" + |
| 8120 | " protected abstract class R0 playedBy T726cwhlp1 {\n" + |
| 8121 | " @SuppressWarnings(\"hidden-lifting-problem\")\n" + |
| 8122 | " bar <- after foo;\n" + |
| 8123 | " abstract void bar();\n" + |
| 8124 | " }\n" + |
| 8125 | " protected class R1 extends R0 {\n" + |
| 8126 | " void bar() { System.out.print(\"NOTOK\"); }\n" + |
| 8127 | " }\n" + |
| 8128 | " protected class R2 extends R0 {\n" + |
| 8129 | " void bar() {\n" + |
| 8130 | " System.out.print(\"OK\");\n" + |
| 8131 | " }\n" + |
| 8132 | " }\n" + |
| 8133 | " void doLift(T726cwhlp1 as R2 r) throws org.objectteams.LiftingFailedException {}\n" + |
| 8134 | " public static void main(String[] args) throws org.objectteams.LiftingFailedException {\n" + |
| 8135 | " Team726cwhlp1 t = new Team726cwhlp1();\n" + |
| 8136 | " t.activate();\n" + |
| 8137 | " T726cwhlp1 b = new T726cwhlp1();\n" + |
| 8138 | " t.doLift(b);\n" + |
| 8139 | " b.foo();\n" + |
| 8140 | " }\n" + |
| 8141 | "}\n", |
| 8142 | "T726cwhlp1.java", |
| 8143 | "public class T726cwhlp1 {\n" + |
| 8144 | " public void foo() { }\n" + |
| 8145 | "}\n" |
| 8146 | }, |
| 8147 | "OK", |
| 8148 | null/*classLibs*/, |
| 8149 | true/*shouldFlush*/, |
| 8150 | null/*vmArguments*/, |
| 8151 | options, |
| 8152 | null/*requester*/); |
| 8153 | } |
| 8154 | // Bug 337413 - [otjld][compiler] consider changing LiftingFailedException to a checked exception |
| 8155 | // callin doesn't fire due to LiftingFailedException behind the scenes (call target lifting) |
| 8156 | public void test726_callinWithHiddenLiftingProblem2() { |
| 8157 | Map options = getCompilerOptions(); |
| 8158 | options.put(CompilerOptions.OPTION_ReportHiddenLiftingProblem, CompilerOptions.WARNING); |
| 8159 | runConformTest( |
| 8160 | new String[] { |
| 8161 | "Team726cwhlp2.java", |
| 8162 | "@SuppressWarnings(\"ambiguousbinding\")\n" + |
| 8163 | "public team class Team726cwhlp2 {\n" + |
| 8164 | " protected class R0 playedBy T726cwhlp2 {\n" + |
| 8165 | " @SuppressWarnings(\"hidden-lifting-problem\")\n" + |
| 8166 | " bar <- after foo;\n" + |
| 8167 | " void bar() {\n" + |
| 8168 | " System.out.print(\"OK\");\n" + |
| 8169 | " }\n" + |
| 8170 | " }\n" + |
| 8171 | " protected class R1 extends R0 {}\n" + |
| 8172 | " protected class R2 extends R0 {}\n" + |
| 8173 | " public static void main(String[] args) {\n" + |
| 8174 | " Team726cwhlp2 t = new Team726cwhlp2();\n" + |
| 8175 | " t.activate();\n" + |
| 8176 | " T726cwhlp2 b = new T726cwhlp2();\n" + |
| 8177 | " b.foo();\n" + |
| 8178 | " }\n" + |
| 8179 | "}\n", |
| 8180 | "T726cwhlp2.java", |
| 8181 | "public class T726cwhlp2 {\n" + |
| 8182 | " public void foo() { }\n" + |
| 8183 | "}\n" |
| 8184 | }, |
| 8185 | "", |
| 8186 | null/*classLibs*/, |
| 8187 | true/*shouldFlush*/, |
| 8188 | null/*vmArguments*/, |
| 8189 | options, |
| 8190 | null/*requester*/); |
| 8191 | } |
| 8192 | // Bug 337413 - [otjld][compiler] consider changing LiftingFailedException to a checked exception |
| 8193 | // callin doesn't fire due to LiftingFailedException behind the scenes (arg lifting in after-callin) |
| 8194 | public void test726_callinWithHiddenLiftingProblem3() { |
| 8195 | Map options = getCompilerOptions(); |
| 8196 | options.put(CompilerOptions.OPTION_ReportHiddenLiftingProblem, CompilerOptions.WARNING); |
| 8197 | runConformTest( |
| 8198 | new String[] { |
| 8199 | "Team726cwhlp3.java", |
| 8200 | "@SuppressWarnings(\"ambiguousbinding\")\n" + |
| 8201 | "public team class Team726cwhlp3 {\n" + |
| 8202 | " protected class ROK playedBy T726cwhlp3 {\n" + |
| 8203 | " @SuppressWarnings(\"hidden-lifting-problem\")\n" + |
| 8204 | " bar <- after foo;\n" + // argument lifting going bad |
| 8205 | " void bar(R0 r) {\n" + |
| 8206 | " System.out.print(\"OK\");\n" + |
| 8207 | " }\n" + |
| 8208 | " }\n" + |
| 8209 | " protected class R0 playedBy T726cwhlp3 {}\n" + |
| 8210 | " protected class R1 extends R0 {}\n" + |
| 8211 | " protected class R2 extends R0 {}\n" + |
| 8212 | " public static void main(String[] args) {\n" + |
| 8213 | " Team726cwhlp3 t = new Team726cwhlp3();\n" + |
| 8214 | " t.activate();\n" + |
| 8215 | " T726cwhlp3 b = new T726cwhlp3();\n" + |
| 8216 | " b.foo(b);\n" + |
| 8217 | " }\n" + |
| 8218 | "}\n", |
| 8219 | "T726cwhlp3.java", |
| 8220 | "public class T726cwhlp3 {\n" + |
| 8221 | " public void foo(T726cwhlp3 b) { }\n" + |
| 8222 | "}\n" |
| 8223 | }, |
| 8224 | "", |
| 8225 | null/*classLibs*/, |
| 8226 | true/*shouldFlush*/, |
| 8227 | null/*vmArguments*/, |
| 8228 | options, |
| 8229 | null/*requester*/); |
| 8230 | } |
| 8231 | // Bug 337413 - [otjld][compiler] consider changing LiftingFailedException to a checked exception |
| 8232 | // callin doesn't fire due to LiftingFailedException behind the scenes (arg lifting in replace-callin) |
| 8233 | public void test726_callinWithHiddenLiftingProblem4() { |
| 8234 | Map options = getCompilerOptions(); |
Stephan Herrmann | 3cef2f0 | 2012-01-29 19:17:03 +0100 | [diff] [blame] | 8235 | options.put(CompilerOptions.OPTION_ReportHiddenLiftingProblem, CompilerOptions.ERROR); |
| 8236 | options.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED); |
Stephan Herrmann | 7aa4219 | 2011-05-10 23:29:37 +0000 | [diff] [blame] | 8237 | runConformTest( |
| 8238 | new String[] { |
| 8239 | "Team726cwhlp4.java", |
| 8240 | "@SuppressWarnings(\"ambiguousbinding\")\n" + |
| 8241 | "public team class Team726cwhlp4 {\n" + |
| 8242 | " protected class ROK playedBy T726cwhlp4 {\n" + |
Stephan Herrmann | 3cef2f0 | 2012-01-29 19:17:03 +0100 | [diff] [blame] | 8243 | " mycallin:\n" + |
Stephan Herrmann | 7aa4219 | 2011-05-10 23:29:37 +0000 | [diff] [blame] | 8244 | " @SuppressWarnings(\"hidden-lifting-problem\")\n" + |
Stephan Herrmann | 3cef2f0 | 2012-01-29 19:17:03 +0100 | [diff] [blame] | 8245 | " bar <- replace foo;\n" + // argument lifting going bad |
Stephan Herrmann | 7aa4219 | 2011-05-10 23:29:37 +0000 | [diff] [blame] | 8246 | " @SuppressWarnings(\"basecall\")\n" + |
| 8247 | " callin void bar(R0 r) {\n" + |
| 8248 | " System.out.print(\"NOK\");\n" + |
| 8249 | " }\n" + |
| 8250 | " }\n" + |
| 8251 | " protected class R0 playedBy T726cwhlp4 {}\n" + |
| 8252 | " protected class R1 extends R0 {}\n" + |
| 8253 | " protected class R2 extends R0 {}\n" + |
| 8254 | " public static void main(String[] args) {\n" + |
| 8255 | " Team726cwhlp4 t = new Team726cwhlp4();\n" + |
| 8256 | " t.activate();\n" + |
| 8257 | " T726cwhlp4 b = new T726cwhlp4();\n" + |
| 8258 | " b.foo(b);\n" + |
| 8259 | " }\n" + |
| 8260 | "}\n", |
| 8261 | "T726cwhlp4.java", |
| 8262 | "public class T726cwhlp4 {\n" + |
| 8263 | " public void foo(T726cwhlp4 b) { System.out.print(\"OK\"); }\n" + |
| 8264 | "}\n" |
| 8265 | }, |
| 8266 | "OK", |
| 8267 | null/*classLibs*/, |
| 8268 | true/*shouldFlush*/, |
| 8269 | null/*vmArguments*/, |
| 8270 | options, |
| 8271 | null/*requester*/); |
| 8272 | } |
Stephan Herrmann | 43574f1 | 2012-08-25 21:41:08 +0200 | [diff] [blame] | 8273 | |
Stephan Herrmann | d9ab5d3 | 2012-08-26 15:10:57 +0200 | [diff] [blame] | 8274 | // Bug 387996 - "T cannot be resolved or is not a field" error due to field named like package |
Stephan Herrmann | 43574f1 | 2012-08-25 21:41:08 +0200 | [diff] [blame] | 8275 | public void testBug387996a() { |
| 8276 | runConformTest( |
| 8277 | new String[] { |
| 8278 | "test/T1.java", |
| 8279 | "package test;\n" + |
| 8280 | "public team class T1 {\n" + |
| 8281 | " private Object test; // = name of package\n" + |
| 8282 | " protected class R playedBy B base when (true) {\n" + |
| 8283 | " void bar() {}\n" + |
| 8284 | " bar <- after foo; // <- warning!\n" + |
| 8285 | " }\n" + |
| 8286 | "}", |
| 8287 | "test/B.java", |
| 8288 | "package test;\n" + |
| 8289 | "public class B { \n" + |
| 8290 | " public void foo() {};\n" + |
| 8291 | "}" |
| 8292 | }); |
| 8293 | } |
Stephan Herrmann | 36d2fc2 | 2010-10-05 20:25:01 +0000 | [diff] [blame] | 8294 | } |