[fpc-devel] Re: JVM: class of XYZ => java.lang.Class

Sven Barth pascaldragon at googlemail.com
Sun Dec 25 18:23:46 CET 2011


On 25.12.2011 18:19, Sven Barth wrote:
> Hello Jonas!
>
> I'm getting along quite well with implementing my first real Android
> application, but now I've hit a little problem: to start a new activity
> I need to pass the class type as a parameter which is declared as
> "java.lang.Class". If I give my class type as a parameter (which derives
> from one of Android's activity classes) the compiler complains with the
> following error:
>
> TrainLog.lpr(249,53) Error: Incompatible type for arg no. 2: Got "Class
> Of TTrainTypeActivity", expected "JLClass"
>
> What is the best way to solve this? I know that there is a "getClass"
> function declared in JLObject, but that is an instance method and I
> don't have an instance of my new activity yet and also I don't think
> that it is wise to construct an instance of an activity class manually.

Ok, I could simply solve this by doing a typecast 
"JLClass(TTrainTypeActivity)", but couldn't the compiler do this 
automatically? (as this looks a bit unclean to me...)

Regards,
Sven




More information about the fpc-devel mailing list