private static boolean isGetMagicClass(JMethod target) { return (target.getName().equals("magicClass") && target.getEnclosingType().getName().equals(GwtReflect.class.getName())) || (target.getName().equals("enhanceClass") && target.getEnclosingType().getName().endsWith(ReflectionUtilJava.MAGIC_CLASS_SUFFIX)) ; }
private boolean canAccessSuperMethod(JDeclaredType type, JMethod method) { if (method.isPrivate()) { return false; } if (method.isDefault()) { // Check package access. String typePackage = Shared.getPackageName(type.getName()); String methodPackage = Shared.getPackageName(method.getEnclosingType().getName()); return typePackage.equals(methodPackage); } return true; }
return null; return injectLazySingleton(logger, classLiteral, x, currentMethod.getEnclosingType(), ast);
@Override public JMethod translate(JMethod method) { if (!method.isExternal()) { return method; } JDeclaredType enclosingType = method.getEnclosingType(); String sig = enclosingType.getName() + '.' + method.getSignature(); JMethod newMethod = methodMap.get(sig); if (newMethod != null) { return newMethod; } enclosingType = translate(enclosingType); if (enclosingType.isExternal()) { assert errorsFound; return method; } mapApi(enclosingType); // Now the method should be there. method = methodMap.get(sig); if (method == null) { // TODO: error logging throw new NoSuchMethodError(sig); } assert !method.isExternal(); return method; } @Override
staticInitialize(method.getEnclosingType()); } else if (method.canBePolymorphic()) { String signature = method.getSignature(); if (pending != null) { for (JMethod p : pending) { assert instantiatedTypes.contains(p.getEnclosingType()); flowInto(p);
private JExpression handleMagicMethodCall(JMethodCall x, Context ctx) { JMethod target = x.getTarget(); String sig = target.getEnclosingType().getName() + '.' + target.getSignature(); if (GWT_CREATE.equals(sig) || OLD_GWT_CREATE.equals(sig)) { return handleGwtCreate(x); } else if (IMPL_GET_NAME_OF.equals(sig)) { return handleImplNameOf(x); } else if (magicMethodMap.containsKey(sig)){ MagicMethodGenerator method = magicMethodMap.get(sig); try { JExpression expr = method.injectMagic(logger, x, currentMethod, ctx, UnifyAst.this); if (logger.isLoggable(Type.DEBUG)){ logger.log(Type.DEBUG, "Magic method "+method +" converted:\n"+x+"\ninto: "+expr); } if (expr instanceof JMethodCall) { flowInto(((JMethodCall)expr).getTarget()); } return expr; } catch (Exception e) { logger.log(Type.ERROR, "Fatal error calling magic method "+method+" on "+x, e); throw new InternalCompilerException("Unable to implement magic method "+method+"()", e); } } throw new InternalCompilerException("Unknown magic method error"); } }
currentMethod.getEnclosingType()); if (result == null) { error(x, "Rebind result '" + answer + "' has no default (zero argument) constructors");
JMethod newMethod = new JMethod(methodSource, "enhanceAll", methodCall.getTarget().getEnclosingType(), ast.getProgram().getTypeVoid(), false, true, true, AccessModifier.PUBLIC); methodCall.getTarget().getEnclosingType().addMethod(newMethod); JMethodCall call = new JMethodCall(methodSource, null, newMethod);
methodCall.getTarget().getEnclosingType(), ast.getProgram().getTypeVoid(), false, true, true, AccessModifier.PUBLIC); methodCall.getTarget().getEnclosingType().addMethod(newMethod); final JMethodCall call = new JMethodCall(methodSource, null, newMethod);
enclosing = method.getEnclosingType();