Example #1
0
JAVA_OBJECT java_lang_Class_getDeclaredMethods__(JAVA_OBJECT me)
{
    //XMLVM_BEGIN_NATIVE[java_lang_Class_getDeclaredMethods__]
    java_lang_Class* thiz = (java_lang_Class*) me;
    __TIB_DEFINITION_TEMPLATE* tib = (__TIB_DEFINITION_TEMPLATE*) thiz->fields.java_lang_Class.tib_;
    int numMethods = tib->numDeclaredMethods;
    Func_OOOO dispatcher = tib->methodDispatcherFunc;
    if (!__TIB_java_lang_reflect_Method.classInitialized) __INIT_java_lang_reflect_Method();
    org_xmlvm_runtime_XMLVMArray* methods = XMLVMArray_createSingleDimension(__CLASS_java_lang_reflect_Method, numMethods);
    JAVA_ARRAY_OBJECT* methodArray = (JAVA_ARRAY_OBJECT*) methods->fields.org_xmlvm_runtime_XMLVMArray.array_;
    JAVA_INT slot = 0;
    for (slot = 0; slot < numMethods; slot++) {
        java_lang_reflect_Method* method = __NEW_java_lang_reflect_Method();
        XMLVM_METHOD_REFLECTION_DATA* currentMethod = (tib->declaredMethods) + slot;
        int numParameters = currentMethod->numParameterTypes;
        org_xmlvm_runtime_XMLVMArray* parameters = XMLVMArray_createSingleDimension(__CLASS_java_lang_Class, numParameters);
        JAVA_ARRAY_OBJECT* parameterArray = (JAVA_ARRAY_OBJECT*) parameters->fields.org_xmlvm_runtime_XMLVMArray.array_;
        int j = 0;
        JAVA_OBJECT** paramTypes = currentMethod->parameterTypes;
        for (j = 0; j < numParameters; j++) {
            parameterArray[j] = *(paramTypes[j]);
        }
        java_lang_String* name = xmlvm_create_java_string(currentMethod->name);
        JAVA_OBJECT*  checkedExceptions = JAVA_NULL;
        int          numCheckedExceptions = 0;
        int          modifiers = 0;
        java_lang_String* signature = xmlvm_create_java_string(currentMethod->signature);
        JAVA_OBJECT  annotations = JAVA_NULL;
        JAVA_OBJECT  parameterAnnotations = JAVA_NULL;
        java_lang_reflect_Method___INIT____java_lang_String_java_lang_Class_java_lang_Class_1ARRAY_java_lang_Class_1ARRAY_int_java_lang_Object_int_java_lang_String_byte_1ARRAY_byte_1ARRAY(method, name, tib->clazz, parameters, checkedExceptions, modifiers, dispatcher, slot, signature, annotations, parameterAnnotations);
        methodArray[slot] = method;
    }
    return methods;
    //XMLVM_END_NATIVE
}
Example #2
0
JAVA_OBJECT java_lang_Class_getDeclaredFields__(JAVA_OBJECT me)
{
    //XMLVM_BEGIN_NATIVE[java_lang_Class_getDeclaredFields__]
    java_lang_Class* thiz = (java_lang_Class*) me;
    __TIB_DEFINITION_TEMPLATE* tib = (__TIB_DEFINITION_TEMPLATE*) thiz->fields.java_lang_Class.tib_;
    int numFields = tib->numDeclaredFields;
    if (!__TIB_java_lang_reflect_Field.classInitialized) __INIT_java_lang_reflect_Field();
    org_xmlvm_runtime_XMLVMArray* fields = XMLVMArray_createSingleDimension(__CLASS_java_lang_reflect_Field, numFields);
    JAVA_ARRAY_OBJECT* fieldsArray = (JAVA_ARRAY_OBJECT*) fields->fields.org_xmlvm_runtime_XMLVMArray.array_;
    int i = 0;
    for (i = 0; i < numFields; i++) {
        java_lang_reflect_Field* field = __NEW_java_lang_reflect_Field();
        XMLVM_FIELD_REFLECTION_DATA* currentField = (tib->declaredFields) + i;
        java_lang_Class* declaringClass = tib->clazz;
        java_lang_String* name = xmlvm_create_java_string(currentField->name);
        java_lang_Class* type = *(currentField->type);
        JAVA_INT modifiers = currentField->modifiers;
        JAVA_INT offset = currentField->offset;
        JAVA_OBJECT* address = currentField->address;
        java_lang_String* signature = xmlvm_create_java_string(currentField->signature);
        org_xmlvm_runtime_XMLVMArray* annotations = currentField->annotations;
        java_lang_reflect_Field___INIT____java_lang_Class_java_lang_String_java_lang_Class_int_int_java_lang_Object_java_lang_String_byte_1ARRAY(field, declaringClass, name, type, modifiers, offset, address, signature, annotations);                                                                                                                     
        fieldsArray[i] = field;
    }
    return fields;
    //XMLVM_END_NATIVE
}
JAVA_OBJECT java_lang_System_getEncoding___int(JAVA_INT n1)
{
    //XMLVM_BEGIN_NATIVE[java_lang_System_getEncoding___int]
    //Get charset from the OS
#ifdef EMSCRIPTEN
	return xmlvm_create_java_string("UTF-8");
#else
    char charset[CHARSETBUFF];
    getOSCharset(charset, CHARSETBUFF);
    return xmlvm_create_java_string(charset);
#endif
    //XMLVM_END_NATIVE
}
Example #4
0
JAVA_OBJECT java_lang_Class_getSimpleName__(JAVA_OBJECT me)
{
    //XMLVM_BEGIN_NATIVE[java_lang_Class_getSimpleName__]
    //TODO not quite correct
    java_lang_Class* thiz = (java_lang_Class*) me;
    __TIB_DEFINITION_TEMPLATE* tib = (__TIB_DEFINITION_TEMPLATE*) thiz->fields.java_lang_Class.tib_;
    return xmlvm_create_java_string(tib->className);
    //XMLVM_END_NATIVE
}
Example #5
0
JAVA_OBJECT java_lang_System_getEncoding___int(JAVA_INT n1)
{
    //XMLVM_BEGIN_NATIVE[java_lang_System_getEncoding___int]
    //Get charset from the OS 
    char charset[CHARSETBUFF];
    getOSCharset(charset, CHARSETBUFF);
    return xmlvm_create_java_string(charset);
    //XMLVM_END_NATIVE
}
Example #6
0
JAVA_OBJECT newJavaNetInetAddressGenericBS (JAVA_ARRAY_BYTE* address, U_32 length,
                                const char* hostName, U_32 scope_id)
{
    org_xmlvm_runtime_XMLVMArray* byte_array;
    java_lang_String* aString;
    BOOLEAN isAnyAddress = 1;
    static JAVA_ARRAY_BYTE IPv4ANY[4] = { 0, 0, 0, 0 };
    static JAVA_ARRAY_BYTE IPv6ANY[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    U_32 i = 0;
    JAVA_OBJECT result = JAVA_NULL;
    
    aString = xmlvm_create_java_string(hostName);
    
    /* check if the address being returned is the any address.  If so we need to check the prefer flags to see how it should be returned
     (either as IPv4 Any or IPv6 ANY) */
    
    if (harmony_supports_ipv6 ())
    {
        /* Figure out if it is the any address */
        for (i = 0; i < length; i++)
        {
            if (address[i] != 0)
            {
                isAnyAddress = 0;
                break;
            }
        }
    }
    else
    {
        /* just do what we used to do without checking */
        isAnyAddress = 0;
    }
    
    /* If it is the any address then set up to return appropriately based on the flags */
    if (isAnyAddress)
    {
        if ((!preferIPv4Stack ()) && (preferIPv6Addresses ()))
        {
            if ((byte_array =
                 newJavaByteArray (IPv6ANY, sizeof (IPv6ANY))) == NULL)
            {
                return NULL;
            }
        }
        else
        {
            if ((byte_array =
                 newJavaByteArray (IPv4ANY, sizeof (IPv4ANY))) == NULL)
            {
                return NULL;
            }
        }
    }
    else
    {
        /* not any so just set up to return the address normally */
        if ((byte_array = newJavaByteArray (address, length)) == NULL)
        {
            return NULL;
        }
    }
    
    if (harmony_supports_ipv6 ())
    {
#ifdef SUPPORTS_SCOPED_GETBYADDR
        if (scope_id != 0) {
            result = java_net_InetAddress_getByAddress___java_lang_String_byte_1ARRAY_int(aString, byte_array, scope_id);
        }
        else {
#endif
            result = java_net_InetAddress_getByAddress___java_lang_String_byte_1ARRAY(aString, byte_array);

#ifdef SUPPORTS_SCOPED_GETBYADDR
        }
#endif
        
    }
    else
    {
        result = __NEW_java_net_InetAddress();
        java_net_InetAddress___INIT____byte_1ARRAY_java_lang_String(result, byte_array, aString);
        //return result;
    }
    
    return result;
}