]> source.dussan.org Git - aspectj.git/commitdiff
Add guard for clone()
authorAndy Clement <aclement@pivotal.io>
Mon, 8 May 2017 19:34:18 +0000 (12:34 -0700)
committerAndy Clement <aclement@pivotal.io>
Mon, 8 May 2017 19:34:18 +0000 (12:34 -0700)
clone is saying it is protected rather than public and so we need
to add a guard to avoid creating accessor for it.

org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java

index 0755476e98f7e52a4baf2d95cb605ee9b6f0f9a6..5bf9946daf20c0f583ea247a24d7bf1daf21d178 100644 (file)
@@ -23,6 +23,7 @@ import org.aspectj.ajdt.internal.compiler.lookup.InterTypeFieldBinding;
 import org.aspectj.ajdt.internal.compiler.lookup.InterTypeMethodBinding;
 import org.aspectj.ajdt.internal.compiler.lookup.PrivilegedFieldBinding;
 import org.aspectj.ajdt.internal.compiler.lookup.PrivilegedHandler;
+import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ASTVisitor;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AllocationExpression;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AssertStatement;
@@ -44,6 +45,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBin
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ProblemFieldBinding;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
 import org.aspectj.weaver.AjcMemberMaker;
 import org.aspectj.weaver.ResolvedMember;
@@ -123,11 +125,16 @@ public class AccessForInlineVisitor extends ASTVisitor {
                        // send.arguments = AstUtil.insert(new ThisReference(send.sourceStart, send.sourceEnd), send.arguments);
                        MethodBinding superAccessBinding = getSuperAccessMethod(send.binding);
                        AstUtil.replaceMethodBinding(send, superAccessBinding);
-               } else if (!isPublic(send.binding)) {
+               } else if (!isPublic(send.binding) && !isCloneMethod(send.binding)) {
                        send.syntheticAccessor = getAccessibleMethod(send.binding, send.actualReceiverType);
                }
 
        }
+       
+       private boolean isCloneMethod(MethodBinding binding) {
+               return (CharOperation.equals(binding.selector, TypeConstants.CLONE)) &&
+                               (CharOperation.equals(binding.declaringClass.compoundName, TypeConstants.JAVA_LANG_OBJECT));
+       }
 
        public void endVisit(AllocationExpression send, BlockScope scope) {
                if (send.binding == null || !send.binding.isValidBinding())