8014461: genstubs creates default native methods

Reviewed-by: alanb
This commit is contained in:
Jonathan Gibbons 2013-05-14 12:55:15 -07:00
parent c51505263f
commit 8530833747

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -37,6 +37,7 @@ import com.sun.tools.javac.api.JavacTool;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.TypeTag;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
import com.sun.tools.javac.tree.JCTree.JCIdent;
@ -204,6 +205,21 @@ public class GenStubs {
tree.docComments = null;
}
/**
* methods: remove method bodies, make methods native
*/
@Override
public void visitClassDef(JCClassDecl tree) {
long prevClassMods = currClassMods;
currClassMods = tree.mods.flags;
try {
super.visitClassDef(tree);;
} finally {
currClassMods = prevClassMods;
}
}
private long currClassMods = 0;
/**
* methods: remove method bodies, make methods native
*/
@ -215,7 +231,11 @@ public class GenStubs {
tree.params = translateVarDefs(tree.params);
tree.thrown = translate(tree.thrown);
if (tree.restype != null && tree.body != null) {
tree.mods.flags |= Flags.NATIVE;
if ((currClassMods & Flags.INTERFACE) != 0) {
tree.mods.flags &= ~Flags.DEFAULT;
} else {
tree.mods.flags |= Flags.NATIVE;
}
tree.body = null;
}
result = tree;