Mercurial > hg > truffle
changeset 7819:aa022eaf1569
class file path retrieval
author | Michael Haupt <michael.haupt@oracle.com> |
---|---|
date | Tue, 19 Feb 2013 11:21:03 +0100 |
parents | c31c0b65f716 |
children | 8959b331ef3e |
files | graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java |
diffstat | 3 files changed, 26 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java Tue Feb 19 08:50:11 2013 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java Tue Feb 19 11:21:03 2013 +0100 @@ -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 @@ -253,4 +253,9 @@ * Returns name of source file of this type. */ String getSourceFileName(); + + /** + * Returns the class file path - if available - of this type, or {@code null}. + */ + String getClassFilePath(); }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java Tue Feb 19 08:50:11 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java Tue Feb 19 11:21:03 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -29,6 +29,7 @@ import java.lang.annotation.*; import java.lang.reflect.*; +import java.net.*; import java.util.*; import com.oracle.graal.api.meta.*; @@ -497,4 +498,16 @@ } return null; } + + @Override + public String getClassFilePath() { + Class<?> cls = mirror(); + String classFileName = MetaUtil.getSimpleName(cls, false); + while (cls.isLocalClass() || cls.isMemberClass()) { + cls = cls.getEnclosingClass(); + classFileName = new StringBuilder(MetaUtil.getSimpleName(cls, false)).append('$').append(classFileName).toString(); + } + URL classFilePath = cls.getResource(classFileName + ".class"); + return classFilePath == null ? null : classFilePath.getPath(); + } }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java Tue Feb 19 08:50:11 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java Tue Feb 19 11:21:03 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -189,4 +189,9 @@ public Class<?> mirror() { return javaMirror; } + + @Override + public String getClassFilePath() { + return null; + } }