IOS Build失败并带有注释

时间:2016-09-22 11:39:38

标签: ios annotations codenameone

如果我使用自定义注释(非常简单的注释),我的IOS构建失败,并显示以下消息:

/var/folders/zh/kb_4hqhn4kg1h0r5dp_6htcm0000gn/T/build5199219966381817658xxx/dist/MyApplication-src/com_we4it_aveedo_TestAnno.m:2:73: error: use of undeclared identifier 'class__java_lang_annotation_Annotation'; did you mean 'class__java_lang_InstantiationException'?
const struct clazz *base_interfaces_for_com_we4it_aveedo_TestAnno[] = {&class__java_lang_annotation_Annotation};
                                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                    class__java_lang_InstantiationException
In file included from /var/folders/zh/kb_4hqhn4kg1h0r5dp_6htcm0000gn/T/build5199219966381817658xxx/dist/MyApplication-src/com_we4it_aveedo_TestAnno.m:1:
In file included from /var/folders/zh/kb_4hqhn4kg1h0r5dp_6htcm0000gn/T/build5199219966381817658xxx/dist/MyApplication-src/MyApplication-Prefix.pch:20:
In file included from /var/folders/zh/kb_4hqhn4kg1h0r5dp_6htcm0000gn/T/build5199219966381817658xxx/dist/MyApplication-src/java_lang_Class.h:8:
/var/folders/zh/kb_4hqhn4kg1h0r5dp_6htcm0000gn/T/build5199219966381817658xxx/dist/MyApplication-src/java_lang_InstantiationException.h:7:21: note: 'class__java_lang_InstantiationException' declared here
extern struct clazz class__java_lang_InstantiationException;

并从构建日志中剪切注释类:

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface TestAnno
{
    public String kuchen();
}

注释码:

Class forName = Class.forName("justForTest");
TestAnno classNameAnnotation = (TestAnno) forName.getAnnotation(TestAnno.class);

在我的应用程序中使用以下代码就足以打破构建。

Class forName = Class.forName("justForTest");
Annotation[] annotation = forName.getAnnotations();
for (Annotation a : annotation)
{
    if (a instanceof TestAnno)
    {
        TestAnno testAnno = (TestAnno) a;

    }
}

问题是导致错误的第二行。 另一种失败的方法是遵循以下代码:

        $location = 'a';
        $this->db->select('l.id, d.guests, l.city, l.country');
        $this->db->from('offers as o');
        $this->db->join('location as l', 'l.id = o.id', 'left');
        $this->db->join('desc as d', 'd.offer_id = o.id', 'left');
        $this->db->where('d.guests', $guests);
        $this->db->where('o.completed', 1);
        $this->db->where('l.country LIKE', $location.'%');
        $this->db->or_where('l.city LIKE', $location.'%');
        $this->db->limit(5);

获取所有注释工作正常,但将其转换为我的显式注释会破坏那里的构建。

是否有另一种方法可以使用注释,或者它是一个错误,还是它甚至不支持IOS?

1 个答案:

答案 0 :(得分:0)

由于我们不支持反射支持运行时注释没有那么多意义,请参阅:https://www.codenameone.com/blog/why-we-dont-support-the-full-java-api.html

由于移动应用程序是静态的并且是提前编译的,因此这不是必需的,也不会为您节省任何费用。