[aspectwerkz-user] Fwd: Problem with field in Interface

Alexandre Vasseur <[email protected]> Thu, 2 Jun 2005 16:56:02 +0200
Newsgroups gmane.comp.java.aspectwerkz.user
Message-ID <[email protected]>
Great Frederic I could reproduce it. It happens when field belongs to
interface and when those are not constant ie not inlined by the javac
compiler.

The fix you propose below is 1/2 exact. You also need to fix
"AsmClassInfo" the same way.

Then
// use java 1.4
ant clean dist
// get the lib/aspectwerkz-2.0.jar

Thanks

---------- Forwarded message ----------
From: Frederic Simon <[email protected]>
Date: Jun 2, 2005 4:30 PM
Subject: Problem with field in Interface
To: Alexandre Vasseur <[email protected]>
Cc: Liran Zelkha <[email protected]>


So adding this code to JavaClassInfo.java should solve the problem.
Don't have time to compile and test. Liran tell me if it works?

    /**
     * Returns a field info by its hash.
     *
     * @param hash
     * @return
     */
    public FieldInfo getField(final int hash) {
        FieldInfo field = (FieldInfo) m_fields.get(hash);
        if (field == null && getSuperclass() != null) {
            field = getSuperclass().getField(hash);
        }
        if (field == null) {
            // Trying to find constants in Interfaces
            ClassInfo[] interfaces = getInterfaces();
            for (int i = 0; i < interfaces.length; i++) {
                ClassInfo ifc = interfaces[i];
                field = ifc.getField(hash);
                if (field != null)
                    break;
            }
        }
        return field;
    }

--
------------------------
Frederic Simon - Technical Expert
AlphaCSP Israel

Phone: +972 9 7442080 * Fax: +972 9 7442082 * Mobile: +972 54 954301
7 Hataasiya St., POBox 2490, Raanana 43100, Israel
http://www.alphacsp.com/
------------------------