Git Product home page Git Product logo

Comments (11)

greenrobot avatar greenrobot commented on August 18, 2024

Thanks for reporting. Could you check your theory, and debug which field is causing trouble here?
de.greenrobot.dao.DaoConfig.reflectProperties(DaoConfig.java:98)
Property property = (Property) field.get(null);

from greendao.

kiefermat avatar kiefermat commented on August 18, 2024

The field is $jacocoData. I quickly googled for it and found the following code http://www.eclemma.org/jacoco/trunk/coverage/org.jacoco.core/org.jacoco.core.internal.instr/InstrSupport.java.html
where the comment says "Name of the field that stores coverage information of a class"

from greendao.

greenrobot avatar greenrobot commented on August 18, 2024

Hmm, strange behavior. Wonder how to deal with that... Maybe just catch the exception, do a warn logging, and continue?

from greendao.

kiefermat avatar kiefermat commented on August 18, 2024

Yes, I also think this should just be ignored

from greendao.

kiefermat avatar kiefermat commented on August 18, 2024

Ok, in the meanwhile I changed the method to work correctly with emma. Would be nice, if you could include the fix in greenDAO code :-)

private static Property[] reflectProperties(Class<? extends AbstractDao<?, ?>> daoClass)
            throws ClassNotFoundException, IllegalArgumentException, IllegalAccessException {
        Class<?> propertiesClass = Class.forName(daoClass.getName() + "$Properties");
        Field[] fields = propertiesClass.getDeclaredFields();
        Map<Integer, Property> propertyMap = new HashMap<Integer, Property>();
        for (Field field : fields) {
            Property property = null;
            try
            {
                property = (Property) field.get(null);
                if(propertyMap.containsKey(property.ordinal))
                { 
                    throw new DaoException("Duplicate property ordinals");
                }
                propertyMap.put(property.ordinal, property);
            }
            catch(IllegalAccessException e)
            {
                // just ignore this, it could be instrumented code and contain additional properties
                // System.out.println(field.getName());
            }
        }
        Property[] properties = new Property[1];
        properties = propertyMap.values().toArray(properties);
        return properties;
    }

from greendao.

kiefermat avatar kiefermat commented on August 18, 2024

We just found a problem with this fix. Due to usage of the hashmap the order of the properties are not kept correctly, if you use more than about 20 columns in a table the order changes and therefore the queries are no longer correct. Using a LinkedHashMap fixes this problem, since it always maintains the order in which the properties have been inserted

from greendao.

greenrobot avatar greenrobot commented on August 18, 2024

The order of properties is given by the field ordinal. I am not sure if your code would take care of that. Let me give it a shot, I'll push a suggestion soon. Hope you can check it later.

from greendao.

greenrobot avatar greenrobot commented on August 18, 2024

Please check 5b3260f if that fixes these issues.

from greendao.

kiefermat avatar kiefermat commented on August 18, 2024

Hmm, no the problem is still existing. I think the problem is not the static modifier but the private modifier. If I change the if statement to

if ((field.getModifiers() & Modifier.STATIC) != 0 && (field.getModifiers() & Modifier.PRIVATE) == 0)

it works.

from greendao.

greenrobot avatar greenrobot commented on August 18, 2024

Thanks for the feedback. With a375028 it checks for static and public modifiers now. I assume this will fix the issue and close it. If there's another problem, let me know.

from greendao.

kiefermat avatar kiefermat commented on August 18, 2024

Ok, it works now. Thanks for fixing!

from greendao.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.