Package org.codehaus.janino.Java

Examples of org.codehaus.janino.Java.FieldAccess


            List l = (List) this.singleStaticImports.get(identifier);
            if (l != null) {
                for (Iterator it = l.iterator(); it.hasNext();) {
                    Object o = it.next();
                    if (o instanceof IField) {
                        FieldAccess fieldAccess = new FieldAccess(
                            location,
                            new SimpleType(location, ((IField) o).getDeclaringIClass()),
                            (IField) o
                        );
                        fieldAccess.setEnclosingBlockStatement(enclosingBlockStatement);
                        return fieldAccess;
                    }
                }
            }
        }

        // JLS3 6.5.2.BL1.B1.B2.2 Static field imported through static-import-on-demand.
        {
            IField importedField = null;
            for (Iterator it = this.staticImportsOnDemand.iterator(); it.hasNext();) {
                IClass iClass = (IClass) it.next();
                IField f = iClass.getDeclaredIField(identifier);
                if (f != null) {
                        // JLS3 7.5.4 Static-Import-on-Demand Declaration
                        if (!UnitCompiler.this.isAccessible(f, enclosingBlockStatement)) continue;

                        if (importedField != null) {
                            UnitCompiler.this.compileError(
                                "Ambiguous static field import: \""
                                + importedField.toString()
                                + "\" vs. \""
                                + f.toString()
                                + "\""
                            );
                        }
                        importedField = f;
                    }
                }
            if (importedField != null) {
                if (!importedField.isStatic()) UnitCompiler.this.compileError("Cannot static-import non-static field");
                FieldAccess fieldAccess = new FieldAccess(
                    location,
                    new SimpleType(location, importedField.getDeclaringIClass()),
                    importedField
                );
                fieldAccess.setEnclosingBlockStatement(enclosingBlockStatement);
                return fieldAccess;
            }
        }

        // Hack: "java" MUST be a package, not a class.
View Full Code Here

TOP

Related Classes of org.codehaus.janino.Java.FieldAccess

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.