0

The code snippet below causes this warning in NetBeans 6.9.

[rawtypes] found raw type: org.openide.nodes.PropertySupport.Reflection
  missing type parameters for generic class org.openide.nodes.PropertySupport.Reflection<T>
Property dataProp = new PropertySupport.Reflection(t, dataStore.getFloat3DClass(),
                        workingData);

/**
 * Gets the Class object associated with the primitive 3d float array (i.e., float[][][]).
 *
 * @return  the Class object.
 */
public Class<?> getFloat3DClass()
{
    if (class3DFloat == null)
    {
       try
       {
           class3DFloat = Class.forName("[[[F");
       }
       catch (ClassNotFoundException ex)
       {
           Exceptions.printStackTrace(ex);
       }
    }

    return class3DFloat;
}

At runtime getFloat3DClass() returns a Class object whose value is class float[][][]. How do I specify this at design time and avoid this warning?

2 Answers 2

2

You need to specify a type parameter for Property and for PropertySupport. You could either use <?> or you could use <float[][][]>. If you do the latter there will be an unavoidable unchecked cast of the result from Class.forName:

Property<float[][][]> dataProp =
    new PropertySupport<float[][][]>.Reflection(t, dataStore.getFloat3DClass(),
                                                workingData);

...

public Class<float[][][]> getFloat3DClass() {
    ...
    if (class3DFloat == null)
    {
        try
        {
            @SuppressWarnings("unchecked")
            Class<float[][][]> tmp = (Class<float[][][]>)Class.forName("[[[F");
            class3DFloat = tmp;
        }
Sign up to request clarification or add additional context in comments.

2 Comments

You're circumnavigating the world to get to next door. At the language level, float[][][] is a class name and supports the class pseudo-field.
That's true. I assumed that the code he provided was just to illustrate the problem he was having in his real code.
1

You're working too hard. Don't use dataStore.getFloat3DClass() when you're making a PropertySupport.Reflection, use float[][][].class and it will work. And the value will be cached by the runtime for you too.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.