Mercurial > hg > graal-jvmci-8
changeset 11521:f521a1db1378
Avoid accessing the code of a method before it has been linked and verified.
Add some javadoc to ResolvedJavaMethod.getCode
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Tue, 03 Sep 2013 18:19:30 +0200 |
parents | 7cca436d600b |
children | dbf968195ca1 |
files | graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaMethod.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java |
diffstat | 2 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaMethod.java Tue Sep 03 18:09:02 2013 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaMethod.java Tue Sep 03 18:19:30 2013 +0200 @@ -34,9 +34,14 @@ /** * Returns the bytecode of this method, if the method has code. The returned byte array does not - * contain breakpoints or non-Java bytecodes. + * contain breakpoints or non-Java bytecodes. This may return null if the + * {@link #getDeclaringClass() holder} is not {@link ResolvedJavaType#isLinked() linked}. * - * @return the bytecode of the method, or {@code null} if {@code getCodeSize() == 0} + * The contained constant pool indices may not be the ones found in the original class file but + * they can be used with the Graal API (e.g. methods in {@link ConstantPool}). + * + * @return the bytecode of the method, or {@code null} if {@code getCodeSize() == 0} or if the + * code is not ready. */ byte[] getCode();
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Tue Sep 03 18:09:02 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Tue Sep 03 18:19:30 2013 +0200 @@ -138,7 +138,7 @@ if (codeSize == 0) { return null; } - if (code == null) { + if (code == null && graalRuntime().getCompilerToVM().isTypeLinked(holder)) { code = graalRuntime().getCompilerToVM().initializeBytecode(metaspaceMethod, new byte[codeSize]); assert code.length == codeSize : "expected: " + codeSize + ", actual: " + code.length; }