-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support of Class.getInterfaces()
- Loading branch information
1 parent
51a3ae9
commit 452133c
Showing
8 changed files
with
93 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package samples.reflection.trivial.getinterfacesexample; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class GetInterfacesExample { | ||
public static void main(String[] args) { | ||
// Interface itself (does not have interfaces, unless it extends another) | ||
printInterfaces(Map.class); | ||
|
||
// Interface extending another interface | ||
printInterfaces(ChildInterface.class); | ||
|
||
printInterfaces(HashMap.class); | ||
|
||
printInterfaces(String[].class); | ||
|
||
printInterfaces(int.class); | ||
} | ||
|
||
static void printInterfaces(Class<?> clazz) { | ||
System.out.print("Interfaces implemented by "); | ||
System.out.print(clazz.getName()); | ||
System.out.println(":"); | ||
Class<?>[] interfaces = clazz.getInterfaces(); | ||
for (Class<?> iface : interfaces) { | ||
System.out.print('\t'); | ||
System.out.println(iface.getName()); | ||
} | ||
} | ||
|
||
interface ChildInterface<K, V> extends Map<K, V>, Runnable { | ||
} | ||
} |
Binary file added
BIN
+498 Bytes
...samples/reflection/trivial/getinterfacesexample/GetInterfacesExample$ChildInterface.class
Binary file not shown.
Binary file added
BIN
+1.27 KB
tests/test_data/samples/reflection/trivial/getinterfacesexample/GetInterfacesExample.class
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters