we can't call this method 'of', cause it won't compile on JDK7
434722
public static <A extends Annotation> EnhancedAnnotation<A> create(SlimAnnotatedType<A> annotatedType, ClassTransformer classTransformer) {

        Class<A> annotationType = annotatedType.getJavaClass();

        Map<Class<? extends Annotation>, Annotation> annotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
        annotationMap.putAll(buildAnnotationMap(annotatedType.getAnnotations()));
        annotationMap.putAll(buildAnnotationMap(classTransformer.getTypeStore().get(annotationType)));
        // Annotations and declared annotations are the same for annotation type
        return new EnhancedAnnotationImpl<A>(annotatedType, annotationMap, annotationMap, classTransformer);
    }
870048
def method_missing(name, *args, &block)
      getter_name = name[0..-2]

      if name =~ /^[a-z]+=$/ && !respond_to?(getter_name)
        define_accessor(getter_name, args.first)
      else
        super
      end
    end
862482
@SuppressWarnings({ "rawtypes", "unchecked" })
	public void callMethod(final MethodCallInfo info) {
		try {
			MethodsCaller.logger.info("loading class : ".concat(info.getClassName()));
			final Class clas = getClass().getClassLoader().loadClass(info.getClassName());
			MethodsCaller.logger.info("calling default constructor");
			final Object object = clas.newInstance();
			MethodsCaller.logger.info("calling method : " + info.getMethodName() + " , with params: ".concat(Arrays.toString(info.getParamters())));
			final Method method = clas.getMethod(info.getMethodName(), info.getParamtersTypes());
			final Object result = method.invoke(object, info.getParamters());
			if (!(result instanceof Serializable)) {
				throw new IllegalStateException("object " + result + " from type " + result.getClass().getName() + " is not serialzable");
			}
			info.setResult(result);
		} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | SecurityException
				| IllegalArgumentException | InvocationTargetException e) {
			MethodsCaller.logger.severe("calling to method failed : ".concat(info.toString()));
			throw new RemoteReflectionException(e);
		}
	}
483934
public final void synpred198_Java_fragment() throws RecognitionException {
		// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1056:7: ( ( variableModifier )* type variableDeclarators )
		// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1056:7: ( variableModifier )* type variableDeclarators
		{
		// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1056:7: ( variableModifier )*
		loop220:
		while (true) {
			int alt220=2;
			int LA220_0 = input.LA(1);
			if ( (LA220_0==58||LA220_0==83) ) {
				alt220=1;
			}

			switch (alt220) {
			case 1 :
				// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1056:9: variableModifier
				{
				pushFollow(FOLLOW_variableModifier_in_synpred198_Java4596);
				variableModifier();
				state._fsp--;
				if (state.failed) return;
				}
				break;

			default :
				break loop220;
			}
		}

		pushFollow(FOLLOW_type_in_synpred198_Java4631);
		type();
		state._fsp--;
		if (state.failed) return;
		pushFollow(FOLLOW_variableDeclarators_in_synpred198_Java4651);
		variableDeclarators();
		state._fsp--;
		if (state.failed) return;
		}

	}
1321362
public final void synpred137_Java_fragment() throws RecognitionException {
		// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:657:9: ( interfaceDeclaration ( ';' )? )
		// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:657:9: interfaceDeclaration ( ';' )?
		{
		pushFollow(FOLLOW_interfaceDeclaration_in_synpred137_Java2595);
		interfaceDeclaration();
		state._fsp--;
		if (state.failed) return;
		// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:657:30: ( ';' )?
		int alt209=2;
		int LA209_0 = input.LA(1);
		if ( (LA209_0==52) ) {
			alt209=1;
		}
		switch (alt209) {
			case 1 :
				// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:657:30: ';'
				{
				match(input,52,FOLLOW_52_in_synpred137_Java2597); if (state.failed) return;
				}
				break;

		}

		}

	}
1087195
@Override public Object invokeMethod(final String name, final Object arguments) {
    if (GantState.dryRun) {
      if (GantState.verbosity > GantState.SILENT) {
        final StringBuilder sb = new StringBuilder();
        int padding = 9 - name.length();
        if (padding < 0) { padding = 0; }
        sb.append("         ".substring(0, padding) + '[' + name + "] ");
        final Object[] args = (Object[]) arguments;
        if (args[0] instanceof Map<?,?>) {
          //////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Eclipse and IntelliJ IDEA warn that (Map) is not a proper cast but using the
          // cast (Map<?,?>) causes a type check error due to the capture algorithm.
          //
          //  TODO : Fix this rather than use a SuppressWarnings.
          //////////////////////////////////////////////////////////////////////////////////////////////////////////
          @SuppressWarnings({ "unchecked", "rawtypes" } ) final Iterator<Map.Entry<?,?>> i =((Map) args[0]).entrySet().iterator();
          while (i.hasNext()) {
            final Map.Entry<?,?> e = i.next();
            sb.append(e.getKey() + " : '" + e.getValue() + '\'');
            if (i.hasNext()) { sb.append(", "); }
          }
          sb.append('\n');
          getProject().log(sb.toString());
          if (args.length == 2) {((Closure<?>) args[1]).call(); }
        }
        else if (args[0] instanceof Closure) { ((Closure<?>) args[0]).call(); }
        else { throw new RuntimeException("Unexpected type of parameter to method " + name); }
      }
      return null;
    }
    return super.invokeMethod(name, arguments);
  }
172968
static int findFunction(Context cx,
                            MemberBox[] methodsOrCtors, Object[] args)
    {
        if (methodsOrCtors.length == 0) {
            return -1;
        } else if (methodsOrCtors.length == 1) {
            MemberBox member = methodsOrCtors[0];
            Class<?>[] argTypes = member.getParameterTypes();
            int alength = argTypes.length;

            if (member.isVarArgs()) {
                alength--;
                if ( alength > args.length) {
                    return -1;
                }
            } else {
                if (alength != args.length) {
                    return -1;
                }
            }
            for (int j = 0; j != alength; ++j) {
                if (!NativeJavaObject.canConvert(args[j], argTypes[j])) {
                    if (debug) printDebug("Rejecting (args can't convert) ",
                                          member, args);
                    return -1;
                }
            }
            if (debug) printDebug("Found ", member, args);
            return 0;
        }

        int firstBestFit = -1;
        int[] extraBestFits = null;
        int extraBestFitsCount = 0;

      search:
        for (int i = 0; i < methodsOrCtors.length; i++) {
            MemberBox member = methodsOrCtors[i];
            Class<?>[] argTypes = member.getParameterTypes();
            int alength = argTypes.length;
            if (member.isVarArgs()) {
                alength--;
                if ( alength > args.length) {
                    continue search;
                }
            } else {
                if (alength != args.length) {
                    continue search;
                }
            }
            for (int j = 0; j < alength; j++) {
                if (!NativeJavaObject.canConvert(args[j], argTypes[j])) {
                    if (debug) printDebug("Rejecting (args can't convert) ",
                                          member, args);
                    continue search;
                }
            }
            if (firstBestFit < 0) {
                if (debug) printDebug("Found first applicable ", member, args);
                firstBestFit = i;
            } else {
                // Compare with all currently fit methods.
                // The loop starts from -1 denoting firstBestFit and proceed
                // until extraBestFitsCount to avoid extraBestFits allocation
                // in the most common case of no ambiguity
                int betterCount = 0; // number of times member was prefered over
                                     // best fits
                int worseCount = 0;  // number of times best fits were prefered
                                     // over member
                for (int j = -1; j != extraBestFitsCount; ++j) {
                    int bestFitIndex;
                    if (j == -1) {
                        bestFitIndex = firstBestFit;
                    } else {
                        bestFitIndex = extraBestFits[j];
                    }
                    MemberBox bestFit = methodsOrCtors[bestFitIndex];
                    if (cx.hasFeature(Context.FEATURE_ENHANCED_JAVA_ACCESS) &&
                        bestFit.isPublic() != member.isPublic())
                    {
                        // When FEATURE_ENHANCED_JAVA_ACCESS gives us access
                        // to non-public members, continue to prefer public
                        // methods in overloading
                        if (bestFit.isPublic())
                            ++betterCount;
                        else
                            ++worseCount;
                    } else {
                        int preference = preferSignature(args, argTypes,
                                                         member.isVarArgs(),
                                                         bestFit.getParameterTypes(),
                                                         bestFit.isVarArgs() );
                        if (preference == PREFERENCE_AMBIGUOUS) {
                            break;
                        } else if (preference == PREFERENCE_FIRST_ARG) {
                            ++betterCount;
                        } else if (preference == PREFERENCE_SECOND_ARG) {
                            ++worseCount;
                        } else {
                            if (preference != PREFERENCE_EQUAL) Kit.codeBug();
                            // This should not happen in theory
                            // but on some JVMs, Class.getMethods will return all
                            // static methods of the class hierarchy, even if
                            // a derived class's parameters match exactly.
                            // We want to call the derived class's method.
                            if (bestFit.isStatic() &&
                                bestFit.getDeclaringClass().isAssignableFrom(
                                       member.getDeclaringClass()))
                            {
                                // On some JVMs, Class.getMethods will return all
                                // static methods of the class hierarchy, even if
                                // a derived class's parameters match exactly.
                                // We want to call the derived class's method.
                                if (debug) printDebug(
                                    "Substituting (overridden static)",
                                    member, args);
                                if (j == -1) {
                                    firstBestFit = i;
                                } else {
                                    extraBestFits[j] = i;
                                }
                            } else {
                                if (debug) printDebug(
                                    "Ignoring same signature member ",
                                    member, args);
                            }
                            continue search;
                        }
                    }
                }
                if (betterCount == 1 + extraBestFitsCount) {
                    // member was prefered over all best fits
                    if (debug) printDebug(
                        "New first applicable ", member, args);
                    firstBestFit = i;
                    extraBestFitsCount = 0;
                } else if (worseCount == 1 + extraBestFitsCount) {
                    // all best fits were prefered over member, ignore it
                    if (debug) printDebug(
                        "Rejecting (all current bests better) ", member, args);
                } else {
                    // some ambiguity was present, add member to best fit set
                    if (debug) printDebug(
                        "Added to best fit set ", member, args);
                    if (extraBestFits == null) {
                        // Allocate maximum possible array
                        extraBestFits = new int[methodsOrCtors.length - 1];
                    }
                    extraBestFits[extraBestFitsCount] = i;
                    ++extraBestFitsCount;
                }
            }
        }

        if (firstBestFit < 0) {
            // Nothing was found
            return -1;
        } else if (extraBestFitsCount == 0) {
            // single best fit
            return firstBestFit;
        }

        // report remaining ambiguity
        StringBuilder buf = new StringBuilder();
        for (int j = -1; j != extraBestFitsCount; ++j) {
            int bestFitIndex;
            if (j == -1) {
                bestFitIndex = firstBestFit;
            } else {
                bestFitIndex = extraBestFits[j];
            }
            buf.append("\n    ");
            buf.append(methodsOrCtors[bestFitIndex].toJavaDeclaration());
        }

        MemberBox firstFitMember = methodsOrCtors[firstBestFit];
        String memberName = firstFitMember.getName();
        String memberClass = firstFitMember.getDeclaringClass().getName();

        if (methodsOrCtors[0].isCtor()) {
            throw Context.reportRuntimeError3(
                "msg.constructor.ambiguous",
                memberName, scriptSignature(args), buf.toString());
        }
        throw Context.reportRuntimeError4(
            "msg.method.ambiguous", memberClass,
            memberName, scriptSignature(args), buf.toString());
    }
1000942
public final void methodDeclaration() throws RecognitionException {
		VarDecl_stack.push(new VarDecl_scope());

		int methodDeclaration_StartIndex = input.index();

		try {
			if ( state.backtracking>0 && alreadyParsedRule(input, 25) ) { return; }

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:385:5: ( type Identifier methodDeclaratorRest )
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:385:7: type Identifier methodDeclaratorRest
			{
			pushFollow(FOLLOW_type_in_methodDeclaration842);
			type();
			state._fsp--;
			if (state.failed) return;
			match(input,Identifier,FOLLOW_Identifier_in_methodDeclaration844); if (state.failed) return;
			pushFollow(FOLLOW_methodDeclaratorRest_in_methodDeclaration846);
			methodDeclaratorRest();
			state._fsp--;
			if (state.failed) return;
			}

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			if ( state.backtracking>0 ) { memoize(input, 25, methodDeclaration_StartIndex); }

			VarDecl_stack.pop();

		}
	}
576638
@Override
    public Object call(PageContext pc, Collection.Key key, Object[] arguments) throws PageException {
	// first check variables
	Object o = shadow.get(key);
	if (o instanceof UDFPlus) {
	    return ((UDFPlus) o).call(pc, key, arguments, false);
	}

	// then check in component
	Member m = component.getMember(access, key, false, false);
	if (m != null) {
	    if (m instanceof UDFPlus) return ((UDFPlus) m).call(pc, key, arguments, false);
	}

	return MemberUtil.call(pc, this, key, arguments, new short[] { CFTypes.TYPE_STRUCT }, new String[] { "struct" });
	// throw ComponentUtil.notFunction(component, key, m!=null?m.getValue():null,access);
    }
817244
StatementDMQL compileCallStatement(RangeVariable[] outerRanges,
                                       boolean isStrictlyProcedure) {

        read();

        if (isIdentifier()) {
            checkValidCatalogName(token.namePrePrefix);

            RoutineSchema routineSchema =
                (RoutineSchema) database.schemaManager.findSchemaObject(
                    token.tokenString,
                    session.getSchemaName(token.namePrefix),
                    SchemaObject.PROCEDURE);

            if (routineSchema != null) {
                read();

                HsqlArrayList list = new HsqlArrayList();

                readThis(Tokens.OPENBRACKET);

                if (token.tokenType == Tokens.CLOSEBRACKET) {
                    read();
                } else {
                    while (true) {
                        Expression e = XreadValueExpression();

                        list.add(e);

                        if (token.tokenType == Tokens.COMMA) {
                            read();
                        } else {
                            readThis(Tokens.CLOSEBRACKET);

                            break;
                        }
                    }
                }

                Expression[] arguments = new Expression[list.size()];

                list.toArray(arguments);

                Routine routine =
                    routineSchema.getSpecificRoutine(arguments.length);
                HsqlList unresolved = null;

                for (int i = 0; i < arguments.length; i++) {
                    Expression e = arguments[i];

                    if (e.isParam()) {
                        e.setAttributesAsColumn(
                            routine.getParameter(i),
                            routine.getParameter(i).isWriteable());
                    } else {
                        int paramMode =
                            routine.getParameter(i).getParameterMode();

                        unresolved =
                            arguments[i].resolveColumnReferences(outerRanges,
                                unresolved);

                        if (paramMode
                                != SchemaObject.ParameterModes.PARAM_IN) {
                            if (e.getType() != OpTypes.VARIABLE) {
                                throw Error.error(ErrorCode.X_42603);
                            }
                        }
                    }
                }

                ExpressionColumn.checkColumnsResolved(unresolved);

                for (int i = 0; i < arguments.length; i++) {
                    arguments[i].resolveTypes(session, null);
                }

                StatementDMQL cs = new StatementProcedure(session, routine,
                    arguments, compileContext);

                return cs;
            }
        }

        if (isStrictlyProcedure) {
            throw Error.error(ErrorCode.X_42501, token.tokenString);
        }

        Expression expression = this.XreadValueExpression();
        HsqlList unresolved = expression.resolveColumnReferences(outerRanges,
            null);

        ExpressionColumn.checkColumnsResolved(unresolved);
        expression.resolveTypes(session, null);

//        expression.paramMode = PARAM_OUT;
        StatementDMQL cs = new StatementProcedure(session, expression,
            compileContext);

        return cs;
    }
1028492
def method_missing(method, *args)
      if (method.to_s =~ /^(.+)(\?|\!)$/)
        value_name = $1.to_sym
        if @state.states.has_key?(value_name)
          case $2
          when '?'
            self.class.class_eval <<-EOC
              def #{method}
                self == #{value_name.inspect}
              end
            EOC
            # Calling `method` on ourselves fails. Something to do
            # w/subclasses. Meh.
            return self == value_name
          when '!'
            self.class.class_eval <<-EOC
              def #{method}
                self.set_value(#{value_name.inspect})
              end
            EOC
            # Calling `method` on ourselves fails. Something to do w/subclasses. Meh.
            return self.set_value(value_name)
          end
        elsif $2 == '?' && aggregates = @state.aggregates[value_name]
          self.class.class_eval <<-EOC
            def #{method}
              @state.aggregates[#{value_name.inspect}].include?(@value)
            end
          EOC
          return aggregates.include?(@value)
        else
          super
        end
      elsif value_for(@value).respond_to?(method)
        value_for(@value).send(method, *args)
      else
        super
      end
    end
506440
public final void mFUNCT() throws RecognitionException {
        try {
            int _type = FUNCT;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // C:\\Project\\Obdalib\\obdalib-parent\\obdalib-core\\src\\main\\java\\it\\unibz\\inf\\obda\\gui\\swing\\utils\\MappingFilter.g:122:6: ( ( 'F' | 'f' ) ( 'U' | 'u' ) ( 'N' | 'n' ) ( 'C' | 'c' ) ( 'T' | 't' ) )
            // C:\\Project\\Obdalib\\obdalib-parent\\obdalib-core\\src\\main\\java\\it\\unibz\\inf\\obda\\gui\\swing\\utils\\MappingFilter.g:122:8: ( 'F' | 'f' ) ( 'U' | 'u' ) ( 'N' | 'n' ) ( 'C' | 'c' ) ( 'T' | 't' )
            {
            if ( input.LA(1)=='F'||input.LA(1)=='f' ) {
                input.consume();
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                recover(mse);
                throw mse;
            }


            if ( input.LA(1)=='U'||input.LA(1)=='u' ) {
                input.consume();
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                recover(mse);
                throw mse;
            }


            if ( input.LA(1)=='N'||input.LA(1)=='n' ) {
                input.consume();
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                recover(mse);
                throw mse;
            }


            if ( input.LA(1)=='C'||input.LA(1)=='c' ) {
                input.consume();
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                recover(mse);
                throw mse;
            }


            if ( input.LA(1)=='T'||input.LA(1)=='t' ) {
                input.consume();
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                recover(mse);
                throw mse;
            }


            }

            state.type = _type;
            state.channel = _channel;
        }
        finally {
        	// do for sure before leaving
        }
    }
1036410
public void compile(Session session) {

        if (!database.schemaManager.schemaExists(compileTimeSchema.name)) {
            compileTimeSchema = session.getSchemaHsqlName(null);
        }

        session.setSchema(compileTimeSchema.name);

        ParserDQL p = new ParserDQL(session, new Scanner(statement));

        p.read();

        viewSubQuery    = p.XreadViewSubquery(this);
        queryExpression = viewSubQuery.queryExpression;

        if (getColumnCount() == 0) {
            if (columnNames == null) {
                columnNames =
                    viewSubQuery.queryExpression.getResultColumnNames();
            }

            if (columnNames.length
                    != viewSubQuery.queryExpression.getColumnCount()) {
                throw Error.error(ErrorCode.X_42593, tableName.statementName);
            }

            TableUtil.setColumnsInSchemaTable(
                this, columnNames, queryExpression.getColumnTypes());
        }

        //
        viewSubqueries = p.compileContext.getSubqueries();

        for (int i = 0; i < viewSubqueries.length; i++) {
            if (viewSubqueries[i].parentView == null) {
                viewSubqueries[i].parentView = this;
            }
        }

        //
        viewSubQuery.getTable().view       = this;
        viewSubQuery.getTable().columnList = columnList;
        schemaObjectNames = p.compileContext.getSchemaObjectNames();
        baseTable                          = queryExpression.getBaseTable();

        if (baseTable == null) {
            return;
        }

        switch (check) {

            case SchemaObject.ViewCheckModes.CHECK_NONE :
                break;

            case SchemaObject.ViewCheckModes.CHECK_LOCAL :
                checkExpression = queryExpression.getCheckCondition();
                break;

            case SchemaObject.ViewCheckModes.CHECK_CASCADE :
                break;

            default :
                throw Error.runtimeError(ErrorCode.U_S0500, "View");
        }
    }
371074
static ObjectMethod objectMethodToOverride(ExecutableElement method) {
    String name = method.getSimpleName().toString();
    switch (method.getParameters().size()) {
      case 0:
        if (name.equals("toString")) {
          return ObjectMethod.TO_STRING;
        } else if (name.equals("hashCode")) {
          return ObjectMethod.HASH_CODE;
        }
        break;
      case 1:
        if (name.equals("equals")) {
          TypeMirror param = getOnlyElement(method.getParameters()).asType();
          if (param.getKind().equals(TypeKind.DECLARED)) {
            TypeElement paramType = MoreTypes.asTypeElement(param);
            if (paramType.getQualifiedName().contentEquals("java.lang.Object")) {
              return ObjectMethod.EQUALS;
            }
          }
        }
        break;
      default:
        // No relevant Object methods have more than one parameter.
    }
    return ObjectMethod.NONE;
  }
1241005
def method_missing(method_name, *args)
      if Color::X11Named.color_names.include?(method_name) && args.empty?
        color(method_name)
      else
        super
      end
    end
264662
public static void callStringBuilderLength(CodeBuilder b) {
        // Because of JDK1.5 bug which exposes AbstractStringBuilder class,
        // cannot use reflection to get method signature.
        TypeDesc stringBuilder = TypeDesc.forClass(StringBuilder.class);
        b.invokeVirtual(stringBuilder, "length", TypeDesc.INT, null);
    }
553930
@SuppressWarnings("deprecation")
    public void compile(String[] classNames) {

        ICompilationUnit[] compilationUnits = new CompilationUnit[classNames.length];
        for (int i = 0; i < classNames.length; i++) {
            compilationUnits[i] = new CompilationUnit(classNames[i]);
        }
        IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.exitOnFirstError();
        IProblemFactory problemFactory = new DefaultProblemFactory(Locale.ENGLISH);

        /**
         * To find types ...
         */
        INameEnvironment nameEnvironment = new INameEnvironment() {

            public NameEnvironmentAnswer findType(final char[][] compoundTypeName) {
                final StringBuffer result = new StringBuffer();
                for (int i = 0; i < compoundTypeName.length; i++) {
                    if (i != 0) {
                        result.append('.');
                    }
                    result.append(compoundTypeName[i]);
                }
                return findType(result.toString());
            }

            public NameEnvironmentAnswer findType(final char[] typeName, final char[][] packageName) {
                final StringBuffer result = new StringBuffer();
                for (int i = 0; i < packageName.length; i++) {
                    result.append(packageName[i]);
                    result.append('.');
                }
                result.append(typeName);
                return findType(result.toString());
            }

            private NameEnvironmentAnswer findStandType(final String name) throws ClassFormatException {
                if (notFoundTypes.contains(name)) {
                    return null;
                }
                RythmEngine engine = engine();
                byte[] bytes = engine.classLoader().getClassDefinition(name);
                if (bytes != null) {
                    ClassFileReader classFileReader = new ClassFileReader(bytes, name.toCharArray(), true);
                    return new NameEnvironmentAnswer(classFileReader, null);
                }
                if (engine.isProdMode()) {
                    notFoundTypes.add(name);
                } else if (name.matches("^(java\\.|play\\.|com\\.greenlaw110\\.).*")) {
                    notFoundTypes.add(name);
                }
                return null;
            }

            private NameEnvironmentAnswer findType(final String name) {
                try {
                    if (!name.contains(TemplateClass.CN_SUFFIX)) {
                        return findStandType(name);
                    }

                    char[] fileName = name.toCharArray();
                    TemplateClass templateClass = classCache.getByClassName(name);

                    // TemplateClass exists
                    if (templateClass != null) {
                        if (templateClass.javaByteCode != null) {
                            ClassFileReader classFileReader = new ClassFileReader(templateClass.javaByteCode, fileName, true);
                            return new NameEnvironmentAnswer(classFileReader, null);
                        }
                        // Cascade compilation
                        ICompilationUnit compilationUnit = new CompilationUnit(name);
                        return new NameEnvironmentAnswer(compilationUnit, null);
                    }

                    // So it's a standard class
                    return findStandType(name);
                } catch (ClassFormatException e) {
                    // Something very very bad
                    throw new RuntimeException(e);
                }
            }

            @Override
            public boolean isPackage(char[][] parentPackageName, char[] packageName) {
                // Rebuild something usable
                StringBuilder sb = new StringBuilder();
                if (parentPackageName != null) {
                    for (char[] p : parentPackageName) {
                        sb.append(new String(p));
                        sb.append(".");
                    }
                }
                sb.append(new String(packageName));
                String name = sb.toString();
                if (packagesCache.containsKey(name)) {
                    return packagesCache.get(name).booleanValue();
                }
                // Check if thera a .java or .class for this resource
                if (engine().classLoader().getClassDefinition(name) != null) {
                    packagesCache.put(name, false);
                    return false;
                }
                if (engine().classes().getByClassName(name) != null) {
                    packagesCache.put(name, false);
                    return false;
                }
                packagesCache.put(name, true);
                return true;
            }

            public void cleanup() {
            }
        };


        /**
         * Compilation result
         */
        ICompilerRequestor compilerRequestor = new ICompilerRequestor() {

            public void acceptResult(CompilationResult result) {
                // If error
                if (result.hasErrors()) {
                    for (IProblem problem : result.getErrors()) {
                        int line = problem.getSourceLineNumber();
                        String message = problem.getMessage();
                        throw CompileException.compilerException(String.valueOf(result.compilationUnit.getMainTypeName()), line, message);
                    }
                }
                // Something has been compiled
                ClassFile[] clazzFiles = result.getClassFiles();
                for (int i = 0; i < clazzFiles.length; i++) {
                    final ClassFile clazzFile = clazzFiles[i];
                    final char[][] compoundName = clazzFile.getCompoundName();
                    final StringBuffer clazzName = new StringBuffer();
                    for (int j = 0; j < compoundName.length; j++) {
                        if (j != 0) {
                            clazzName.append('.');
                        }
                        clazzName.append(compoundName[j]);
                    }

                    if (logger.isTraceEnabled()) {
                        logger.trace("Compiled %s", getTemplateByClassName(clazzName.toString()));
                    }

                    String cn = clazzName.toString();
                    TemplateClass tc = classCache.getByClassName(cn);
                    if (null == tc) {
                        int pos = cn.indexOf("$");
                        if (-1 != pos) {
                            // inner class
                            TemplateClass root = classCache.getByClassName(cn.substring(0, pos));
                            tc = TemplateClass.createInnerClass(cn, clazzFile.getBytes(), root);
                            tc.delayedEnhance(root);
                            classCache.add(tc);
                        } else {
                            throw new RuntimeException("Cannot find class by name: " + cn);
                        }
                    } else {
                        tc.compiled(clazzFile.getBytes());
                    }
                }
            }
        };

        /**
         * The JDT compiler
         */
        Compiler jdtCompiler = new Compiler(nameEnvironment, policy, settings, compilerRequestor, problemFactory) {

            @Override
            protected void handleInternalException(Throwable e, CompilationUnitDeclaration ud, CompilationResult result) {
            }
        };

        // Go !
        jdtCompiler.compile(compilationUnits);

    }