-4

I am developing in Java on Eclipse, I have an API and I would like to share with my other developers. In order to protect the code i would like to export / delete content of all my eclipse methods.

I would just like to leave the statements.

What I currently have

What I would like to have

I have a lot of files and methods so I would like to know if there is not a program / plugins to do that for me.

Neuron
  • 5,141
  • 5
  • 38
  • 59
  • What exactly does "protect the code from your other developers" mean? Why do you want to do it? – Thorbjørn Ravn Andersen Jun 16 '18 at 22:03
  • 1
    Try: https://stackoverflow.com/questions/4622633/automated-way-to-extract-interfaces-from-a-java-class – Pavel Molchanov Jun 16 '18 at 22:05
  • 2
    Actually, he wants to extract interface and give developers interface to implement – Pavel Molchanov Jun 16 '18 at 22:06
  • 1
    Welcome to Stack Overflow! Please, [don't post your code/error messages as images](https://meta.stackoverflow.com/a/285557/4298200). We are not able to copy/paste from images and secondly search engines are unable to index that information. So please make sure that any textual information is actually provided in text form. – Neuron Jun 16 '18 at 22:09
  • Generate **javadoc**. That will document all the public methods without method bodies. You can even write some actual documentation describing what the methods are supposed to do. – Andreas Jun 16 '18 at 22:12

1 Answers1

0

It is not at all clear what you are trying to do.


If you are (literally) wanting to "gut" your classes and provide people with skeletons, then:

  1. I am not aware of an existing Eclipse plugin or other tool to do it. (And asking us to find / recommend software is off-topic.)

  2. It is probably a bad idea anyway. Certainly, this is not what people normally mean by "sharing your code".

  3. There are better alternatives:

    • Give people the compiled code (don't obfuscate it!) and they can discover the API's using an IDE. Depending on the compilation flags, you may lose the names of method parameters. Make sure you compile with maximal "debug" information.

    • Generate and provide javadocs. This will provide people the same information as your "stripped" source code.


On the other hand, if you real goal is to provide an API that other people can implement, the correct way to do it is to define the API using interfaces rather than classes. And Eclipse does support that. There are standard Eclipse refactors that will extract a Java interface from the source code of an existing Java class.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216