From 0f676f68c13d5e18864f7bc9f4a022ff6291ff22 Mon Sep 17 00:00:00 2001 From: Kostya Date: Wed, 22 Jul 2026 09:21:23 +0000 Subject: project bootstrap --- ex1/.mvn/jvm.config | 0 ex1/.mvn/maven.config | 0 ex1/pom.xml | 90 ++++++++++++++ ex1/reflection/api/Investigator.java | 145 ---------------------- ex1/src/main/java/com/reflection/api/App.java | 10 ++ ex1/src/test/java/com/reflection/api/AppTest.java | 19 +++ 6 files changed, 119 insertions(+), 145 deletions(-) create mode 100644 ex1/.mvn/jvm.config create mode 100644 ex1/.mvn/maven.config create mode 100644 ex1/pom.xml delete mode 100644 ex1/reflection/api/Investigator.java create mode 100644 ex1/src/main/java/com/reflection/api/App.java create mode 100644 ex1/src/test/java/com/reflection/api/AppTest.java diff --git a/ex1/.mvn/jvm.config b/ex1/.mvn/jvm.config new file mode 100644 index 0000000..e69de29 diff --git a/ex1/.mvn/maven.config b/ex1/.mvn/maven.config new file mode 100644 index 0000000..e69de29 diff --git a/ex1/pom.xml b/ex1/pom.xml new file mode 100644 index 0000000..3962137 --- /dev/null +++ b/ex1/pom.xml @@ -0,0 +1,90 @@ + + + 4.0.0 + + com.reflection.api + ex1 + 1.0-SNAPSHOT + + ex1 + + http://www.example.com + + + UTF-8 + 17 + + + + + + org.junit + junit-bom + 5.11.0 + pom + import + + + + + + + org.junit.jupiter + junit-jupiter-api + test + + + + org.junit.jupiter + junit-jupiter-params + test + + + + + + + + + maven-clean-plugin + 3.4.0 + + + + maven-resources-plugin + 3.3.1 + + + maven-compiler-plugin + 3.13.0 + + + maven-surefire-plugin + 3.3.0 + + + maven-jar-plugin + 3.4.2 + + + maven-install-plugin + 3.1.2 + + + maven-deploy-plugin + 3.1.2 + + + + maven-site-plugin + 3.12.1 + + + maven-project-info-reports-plugin + 3.6.1 + + + + + diff --git a/ex1/reflection/api/Investigator.java b/ex1/reflection/api/Investigator.java deleted file mode 100644 index 53e4fab..0000000 --- a/ex1/reflection/api/Investigator.java +++ /dev/null @@ -1,145 +0,0 @@ -package reflection.api; - -import java.util.Set; - -public interface Investigator { - - /** - * loads in instance of a given class, which you will need to investigate through means of reflection - * and supply information on... - * - * @param anInstanceOfSomething an instance of an unknown type... - */ - void load(Object anInstanceOfSomething); - - /** - * returns the total number of the current class methods (not including the super class methods) - * the total number of methods includes all sorts of modifiers: private, public, static, protected etc. - * it does not contains constructors of any sort - * - * @return total number of methods - */ - int getTotalNumberOfMethods(); - - /** - * returns the total number of constructors that this class has. (not including the super class constructors) - * the total number of constructors includes all sorts of modifiers: private, public, protected, default etc. - * - * @return total number of constructors - */ - int getTotalNumberOfConstructors(); - - /** - * returns the total number of fields that this class has. - * the total number of fields DOES NOT include fields inherited from super class, if such exists - * and includes all fields of any type (final, static etc.) - * - * @return the total number of fields - */ - int getTotalNumberOfFields(); - - /** - * returns the names of all the interfaces that this class implements - * (and NOT the ones that are being implemented by it's ancestor in the inheritance chain) - * Note that by name I mean simple, short Name that is only the interface name, - * and not its fully qualified name including the package it is located within... - * - * @return set of interfaces names - */ - Set getAllImplementedInterfaces(); - - /** - * returns total number of constant fields (=final), of any type (private, public, static etc.) - * (not including the super class fields) - * @return total number of constant fields - */ - int getCountOfConstantFields(); - - /** - * returns total number of static methods, of any type (private, public etc.), - * that are declared on the instance itself (and not part of its inheritance chain) - * - * @return total number of static methods - */ - int getCountOfStaticMethods(); - - /** - * checks if the given class extends a super class, that is not Object (which all extend by default, implicitly) - * - * @return true if the class extends, false otherwise - */ - boolean isExtending(); - - /** - * get the name of the direct parent class - * the name of the class is the short, simple name and not the fully qualified name - * - * @return the name of the parent class. null if this class doesn't extend other class - */ - String getParentClassSimpleName(); - - /** - * checks if the given class parent is of type abstract - * - * @return true if the parent class is abstract, false otherwise (also in case the given class does not extends any other class) - */ - boolean isParentClassAbstract(); - - /** - * get all the names of all fields, including the ones coming from the inheritance chain - * all fields of any type should exists: private, public, protected, static etc. - * - * @return set of fields names - */ - Set getNamesOfAllFieldsIncludingInheritanceChain(); - - /** - * invokes a method that returns an int value, on the given instance. - * the method to invoke will be given by its name only. - * You can assume that there is exactly one such method and that - * the method is declared on the instance itself and not as part of its inheritance chain - * - * @param methodName the name of the method to invoke - * @param args the arguments to pass to the method, if such exists. - * Note: You should not use the arguments in order to extract and identify the method. - * You can do that only (and simply) by its name. - * You just need to pass the arguments AS IS to the method invocation... - * - * @return the result returned from the method invocation - */ - int invokeMethodThatReturnsInt(String methodName, Object... args); - - /** - * creates a new instance of the given class, using a specific constructor, - * to be determined by the number of given arguments. - * No worries: there will be no ambiguity, i.e. two constructors that gets in 2 arguments each one of them... - * This method should act as a standalone and without any side effects, that is, the newly created - * instance SHOULD NOT replace the original given instance. - * @param numberOfArgs number of arguments that a specific constructor has. can be 0. - * @param args arguments to pass to the constructor - * - * @return the newly created instance - */ - Object createInstance(int numberOfArgs, Object... args); - - /** - * changes access control of a method and invokes it (== invokes a private method...) - * you can assume that the method exists by it's name, and matched by the relevant parameters types. - * - * @param name name of the method to change its access modifier - * @param parametersTypes the types of parameters the method accepts - * @param args arguments to pass to the method invocation AS IS (once elevated) - * - * @return the result from the method invocation - */ - Object elevateMethodAndInvoke(String name, Class[] parametersTypes, Object... args); - - /** - * explores the inheritance chain of the object. returns a string representing the list of - * parents this class has, starting from Object, and ending at the class name. - * all classes names in the list should appear in their simple short name - * @param delimiter a string to put between each two classes in the chain (e.g. "->") - * @return a string denotes the inheritance chain. - * It can look like this (given a decimeter of "->"): Object->->...-> - */ - String getInheritanceChain(String delimiter);} diff --git a/ex1/src/main/java/com/reflection/api/App.java b/ex1/src/main/java/com/reflection/api/App.java new file mode 100644 index 0000000..04cd919 --- /dev/null +++ b/ex1/src/main/java/com/reflection/api/App.java @@ -0,0 +1,10 @@ +package com.reflection.api; + +/** + * Hello world! + */ +public class App { + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/ex1/src/test/java/com/reflection/api/AppTest.java b/ex1/src/test/java/com/reflection/api/AppTest.java new file mode 100644 index 0000000..70f7e97 --- /dev/null +++ b/ex1/src/test/java/com/reflection/api/AppTest.java @@ -0,0 +1,19 @@ +package com.reflection.api; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +/** + * Unit test for simple App. + */ +public class AppTest { + + /** + * Rigorous Test :-) + */ + @Test + public void shouldAnswerWithTrue() { + assertTrue(true); + } +} -- cgit v1.2.3