1 /* 2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 package jdk.jdeprusage; 25 26 import jdk.deprcases.members.ExampleClass; 27 import jdk.deprcases.members.ExampleInterface; 28 import jdk.deprcases.members.ExampleSubclass; 29 30 public class UseMethod { 31 static class Direct { m(ExampleClass ec)32 void m(ExampleClass ec) { 33 ec.method1(); 34 } 35 } 36 37 static class Inherited { m(ExampleSubclass esc)38 void m(ExampleSubclass esc) { 39 esc.method2(); 40 } 41 } 42 43 static class InheritedDefault { m(ExampleSubclass esc)44 void m(ExampleSubclass esc) { 45 esc.defaultMethod(); 46 } 47 } 48 49 static class InterfaceDirect { m(ExampleInterface ei)50 void m(ExampleInterface ei) { 51 ei.interfaceMethod1(); 52 } 53 } 54 55 static class InterfaceDefault { m(ExampleInterface ei)56 void m(ExampleInterface ei) { 57 ei.defaultMethod(); 58 } 59 } 60 61 static class ClassStatic { m()62 void m() { 63 ExampleClass.staticmethod1(); 64 } 65 } 66 67 static class InterfaceStatic { m()68 void m() { 69 ExampleInterface.staticmethod2(); 70 } 71 } 72 73 static class SuperFromSubclass extends ExampleClass { m()74 void m() { 75 super.method1(); 76 } 77 } 78 79 static class InheritedFromSubclass extends ExampleClass { m()80 void m() { 81 method1(); 82 } 83 } 84 85 static class Constructor { m()86 Object m() { 87 return new ExampleClass(true); 88 } 89 } 90 91 static class ConstructorFromSubclass extends ExampleClass { ConstructorFromSubclass()92 public ConstructorFromSubclass() { 93 super(true); 94 } 95 } 96 97 abstract static class InheritedInterfaceDefault extends ExampleSubclass { m()98 void m() { 99 defaultMethod(); 100 } 101 } 102 103 abstract static class InheritedInterface extends ExampleSubclass { m()104 void m() { 105 interfaceMethod1(); 106 } 107 } 108 109 static class OverrideClassMethod extends ExampleClass { 110 @Override method1()111 public void method1() { } 112 } 113 114 abstract static class OverrideInterfaceMethod implements ExampleInterface { 115 @Override interfaceMethod1()116 public void interfaceMethod1() { } 117 } 118 119 abstract static class OverrideDefaultMethod implements ExampleInterface { 120 @Override defaultMethod()121 public void defaultMethod() { } 122 } 123 } 124