I have a question on my java homework that is asking me to generate .java source file from .class file using reflection API.
I'm trying to figure out if it is asking me to instantiate an instance of that class using reflection or actually generate a source file, because from I've read generating a .java file using reflection isn't possible.
Anyone with more experience who could help clarify this for me would be awesome.
You're right: that's not what the reflection API is for. You could write code to use the reflection API to generate the "stub" of a class, e.g. the class declaration, the method declarations (etc) - but you shouldn't expect it to generate that itself, nor to make it easy to decompile source code for the implementations of methods/constructors.
My guess is that "generate the declarations" is all you're being asked to do - although you should check that with whoever assigned you the homework.
See more on this question at Stackoverflow