8014461: genstubs creates default native methods

Tue, 14 May 2013 12:55:15 -0700

author
jjg
date
Tue, 14 May 2013 12:55:15 -0700
changeset 1753
46b9c25f7024
parent 1752
c09b7234cded
child 1754
0384683c64be

8014461: genstubs creates default native methods
Reviewed-by: alanb

make/tools/genstubs/GenStubs.java file | annotate | diff | comparison | revisions
     1.1 --- a/make/tools/genstubs/GenStubs.java	Tue May 14 11:11:09 2013 -0700
     1.2 +++ b/make/tools/genstubs/GenStubs.java	Tue May 14 12:55:15 2013 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -37,6 +37,7 @@
    1.11  import com.sun.tools.javac.code.Flags;
    1.12  import com.sun.tools.javac.code.TypeTag;
    1.13  import com.sun.tools.javac.tree.JCTree;
    1.14 +import com.sun.tools.javac.tree.JCTree.JCClassDecl;
    1.15  import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
    1.16  import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
    1.17  import com.sun.tools.javac.tree.JCTree.JCIdent;
    1.18 @@ -208,6 +209,21 @@
    1.19           * methods: remove method bodies, make methods native
    1.20           */
    1.21          @Override
    1.22 +        public void visitClassDef(JCClassDecl tree) {
    1.23 +            long prevClassMods = currClassMods;
    1.24 +            currClassMods = tree.mods.flags;
    1.25 +            try {
    1.26 +                super.visitClassDef(tree);;
    1.27 +            } finally {
    1.28 +                currClassMods = prevClassMods;
    1.29 +            }
    1.30 +        }
    1.31 +        private long currClassMods = 0;
    1.32 +
    1.33 +        /**
    1.34 +         * methods: remove method bodies, make methods native
    1.35 +         */
    1.36 +        @Override
    1.37          public void visitMethodDef(JCMethodDecl tree) {
    1.38              tree.mods = translate(tree.mods);
    1.39              tree.restype = translate(tree.restype);
    1.40 @@ -215,7 +231,11 @@
    1.41              tree.params = translateVarDefs(tree.params);
    1.42              tree.thrown = translate(tree.thrown);
    1.43              if (tree.restype != null && tree.body != null) {
    1.44 -                tree.mods.flags |= Flags.NATIVE;
    1.45 +                if ((currClassMods & Flags.INTERFACE) != 0) {
    1.46 +                    tree.mods.flags &= ~Flags.DEFAULT;
    1.47 +                } else {
    1.48 +                    tree.mods.flags |= Flags.NATIVE;
    1.49 +                }
    1.50                  tree.body = null;
    1.51              }
    1.52              result = tree;

mercurial