Compile Java code without dependencies

I have a source for a java program, but I do not have its dependencies. Is it possible to compile Java code that uses fields, classes, and methods that cannot be resolved? If not, is there an Eclipse program or plugin that will automatically generate fake classes, variables, and methods that cannot be resolved at compile time? Give examples.

public class Main {
    public static void main(String[] args) {
        // ...
        UnknownClass.unknownMethod();
    }
}

I want it to automatically generate a class UnknownClassusing the method unknownMethod():

public class UnknownClass {
    public static void unknownMethod() {}
}

But do not export it to the output .jar file

+4
source share
1 answer

Java-, , , ?

. .

, Eclipse, , , ?

AFAIK, β„–.

, , ​​. , . , ; , .

( , , , , , varargs, , , , - .)


CraftBukkit.jar Bukkit.jar? Bukkit.jar , BUkkit.jar Craftbukkit.jar.

, . Bukkit JAR, . .

, , ... , ( ), .


:

   UnknownClass c = ...
   c.method(42);
   c.method(42.0);

:

   public class UnknownClass ... {
       void method(double arg) {...}
   }

   public class UnknownClass ... {
       int method(double arg) {...}
   }

   public class UnknownClass ... {
       void method(int arg) {...}
       void method(double arg) {...}
   }

   public class UnknownClass ... {
       void method(byte arg) {...}
       void method(double arg) {...}
   }

   public class UnknownClass ... {
       void method(double... arg) {...}
   }

..

: ; , UnknownClass?

: ! , , , , loader JAR, .

+3

Source: https://habr.com/ru/post/1548290/


All Articles