What is the equivalent of the Java expression "Class.class" in Oxygene?

StackOverflow https://stackoverflow.com/questions/19085152

  •  29-06-2022
  •  | 
  •  

Вопрос

In some Java source for Android I see expressions involving a "class" member on Class types, for example when constructing a ComponentName object:

cname := new ComponentName( this, SomeClass.class );

This does not compile in Oxygene for Java, with the compiler claiming that there is no such static member 'class' on the type.

What is the equivalent Oxygene syntax ?

Это было полезно?

Решение

The "class" member of a Class type in Java is not part of the Java object model but is interpreted directly by the Java compiler. What is sometimes called "compiler magic".

The equivalent compiler magic in Oxygene is the typeof() built-in function:

cname := new ComponentName( self, typeof(SomeClass) );
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top