View | Details | Raw Unified | Return to bug 355315
Collapse All | Expand All

(-)compiler/org/eclipse/objectteams/otdt/core/compiler/InferenceKind.java (-1 / +11 lines)
Lines 32-36 Link Here
32
	/** Callout inferred from a reading field access (via 'this'). */
32
	/** Callout inferred from a reading field access (via 'this'). */
33
	FIELDGET, 
33
	FIELDGET, 
34
	/** Callout inferred from a writing field access (via 'this'). */
34
	/** Callout inferred from a writing field access (via 'this'). */
35
	FIELDSET 
35
	FIELDSET;
36
37
	/** 
38
	 * Some inferred callouts generate private methods that are not advertised in the interface,
39
	 * Answer if this callout binding is advertised in the interface. 
40
	 */
41
	public boolean isAdvertisedInInterface() {
42
		if (this == NONE || this == INTERFACE)
43
			return true;
44
		return false;
45
	}
36
}
46
}
(-)compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CalloutImplementor.java (-1 / +1 lines)
Lines 461-467 Link Here
461
		{
461
		{
462
			if ((modifiers & AccPrivate) != 0) { // don't advertize in ifc
462
			if ((modifiers & AccPrivate) != 0) { // don't advertize in ifc
463
				// FIXME(SH): need to generate bridge methdods?
463
				// FIXME(SH): need to generate bridge methdods?
464
			} else if (calloutBindingDeclaration.binding.inferred == InferenceKind.NONE) { // only if actually advertised in the ifc-part
464
			} else if (calloutBindingDeclaration.binding.inferred.isAdvertisedInInterface()) { // only if actually advertised in the ifc-part
465
				// generated callout method must be public in the classPart.
465
				// generated callout method must be public in the classPart.
466
				// access control is done only via the interface part.
466
				// access control is done only via the interface part.
467
				MethodModel.getModel(newMethod).storeModifiers(newMethod.modifiers);
467
				MethodModel.getModel(newMethod).storeModifiers(newMethod.modifiers);
(-)otjld/org/eclipse/objectteams/otdt/tests/otjld/calloutbinding/CalloutMethodBinding.java (-13 / +54 lines)
Lines 432-451 Link Here
432
        
432
        
433
        runNegativeTest(
433
        runNegativeTest(
434
             new String[] {
434
             new String[] {
435
 		"T311acb1Main.java",
435
 		"T311acb8Main.java",
436
 			    "\n" +
436
 			    "\n" +
437
 			    "public class T311acb1Main {\n" +
437
 			    "public class T311acb8Main {\n" +
438
 			    "    public static void main(String[] args) {\n" +
438
 			    "    public static void main(String[] args) {\n" +
439
 			    "        Team311acb2 t = new Team311acb2();\n" +
439
 			    "        Team311acb2 t = new Team311acb2();\n" +
440
 			    "        T311acb1_1  o = new T311acb1_1();\n" +
440
 			    "        T311acb8_1  o = new T311acb8_1();\n" +
441
 			    "\n" +
441
 			    "\n" +
442
 			    "        System.out.print(t.getValue(o));\n" +
442
 			    "        System.out.print(t.getValue(o));\n" +
443
 			    "    }\n" +
443
 			    "    }\n" +
444
 			    "}\n" +
444
 			    "}\n" +
445
 			    "    \n",
445
 			    "    \n",
446
 		"T311acb1_1.java",
446
 		"T311acb8_1.java",
447
 			    "\n" +
447
 			    "\n" +
448
 			    "public class T311acb1_1 {\n" +
448
 			    "public class T311acb8_1 {\n" +
449
 			    "    public String getValue() {\n" +
449
 			    "    public String getValue() {\n" +
450
 			    "        return getValueInternal();\n" +
450
 			    "        return getValueInternal();\n" +
451
 			    "    }\n" +
451
 			    "    }\n" +
Lines 456-476 Link Here
456
 			    "    \n",
456
 			    "    \n",
457
	    "Team311acb2.java",
457
	    "Team311acb2.java",
458
 			    "\n" +
458
 			    "\n" +
459
 			    "public team class Team311acb2 extends Team311acb1 {\n" +
459
 			    "public team class Team311acb2 extends Team311acb8 {\n" +
460
 			    "    @Override\n" +
460
 			    "    @Override\n" +
461
 			    "    public class Role311acb1 playedBy T311acb1_1 {\n" +
461
 			    "    public class Role311acb8 playedBy T311acb8_1 {\n" +
462
 			    "        getValue -> getValue;\n" +
462
 			    "        getValue -> getValue;\n" +
463
 			    "    }\n" +
463
 			    "    }\n" +
464
 			    "\n" +
464
 			    "\n" +
465
 			    "    public String getValue(T311acb1_1 as Role311acb1 obj) {\n" +
465
 			    "    public String getValue(T311acb8_1 as Role311acb8 obj) {\n" +
466
 			    "        return obj.getValueInternal();\n" +
466
 			    "        return obj.getValueInternal();\n" +
467
 			    "    }\n" +
467
 			    "    }\n" +
468
 			    "}\n",
468
 			    "}\n",
469
 		"Team311acb1.java",
469
 		"Team311acb8.java",
470
 			    "\n" +
470
 			    "\n" +
471
 			    "public abstract team class Team311acb1 {\n" +
471
 			    "public abstract team class Team311acb8 {\n" +
472
 			    "\n" +
472
 			    "\n" +
473
 			    "    public abstract class Role311acb1 {\n" +
473
 			    "    public abstract class Role311acb8 {\n" +
474
 			    "        public abstract String getValue();\n" +
474
 			    "        public abstract String getValue();\n" +
475
 			    "        public abstract String getValueInternal();\n" +
475
 			    "        public abstract String getValueInternal();\n" +
476
 			    "    }\n" +
476
 			    "    }\n" +
Lines 480-488 Link Here
480
            "----------\n" + 
480
            "----------\n" + 
481
			"1. ERROR in Team311acb2.java (at line 1)\n" + 
481
			"1. ERROR in Team311acb2.java (at line 1)\n" + 
482
			"	\n" + 
482
			"	\n" + 
483
			"public team class Team311acb2 extends Team311acb1 {\n" + 
483
			"public team class Team311acb2 extends Team311acb8 {\n" + 
484
			"	^\n" + 
484
			"	^\n" + 
485
			"The abstract method getValueInternal in type Role311acb1 can only be defined by an abstract class\n" + 
485
			"The abstract method getValueInternal in type Role311acb8 can only be defined by an abstract class\n" + 
486
			"----------\n");
486
			"----------\n");
487
     }
487
     }
488
488
Lines 2779-2784 Link Here
2779
            null/*no custom requestor*/);
2779
            null/*no custom requestor*/);
2780
    }
2780
    }
2781
2781
2782
    // Bug 355315 - callout inferred to implement protected method causes IllegalAccessError
2783
    public void test3117_inferredCallout11() {
2784
       Map customOptions = getCompilerOptions();
2785
       customOptions.put(CompilerOptions.OPTION_ReportInferredCallout, CompilerOptions.WARNING);
2786
       
2787
       runConformTest(
2788
            new String[] {
2789
		"Team3117ic11.java",
2790
			    "\n" +
2791
			    "public team class Team3117ic11 {\n" +
2792
			    "    @SuppressWarnings(\"inferredcallout\")\n" +
2793
			    "    protected class R1 extends R0 playedBy T3117ic11 {\n" +
2794
			    "    }\n" +
2795
			    "    protected abstract class R0 {\n" +
2796
			    "        abstract protected void test();\n" +
2797
			    "    }\n" +
2798
			    "    Team3117ic11() {\n" +
2799
			    "        new R1(new T3117ic11()).test();\n" +
2800
			    "    }\n" +
2801
			    "    public static void main(String[] args) {\n" +
2802
			    "        new Team3117ic11();\n" +
2803
			    "    }\n" +
2804
			    "}\n" +
2805
			    "    \n",
2806
		"T3117ic11.java",
2807
			    "\n" +
2808
			    "public class T3117ic11 {\n" +
2809
			    "    public void test() {\n" +
2810
			    "        System.out.print(\"OK\");\n" +
2811
			    "    }\n" +
2812
			    "}\n" +
2813
			    "    \n"
2814
            },
2815
            "OK",
2816
            null/*classLibraries*/,
2817
            true/*shouldFlushOutputDirectory*/,
2818
            null/*vmArguments*/,
2819
            customOptions,
2820
            null/*no custom requestor*/);
2821
    }
2822
2782
    // a short callout binding lacks a rhs
2823
    // a short callout binding lacks a rhs
2783
    // 3.1.18-otjld-incomplete-callout-binding-1
2824
    // 3.1.18-otjld-incomplete-callout-binding-1
2784
    public void test3118_incompleteCalloutBinding1() {
2825
    public void test3118_incompleteCalloutBinding1() {

Return to bug 355315