# HG changeset patch # User Michael Haupt # Date 1361269263 -3600 # Node ID aa022eaf15692d78455583c001cf59086524aa13 # Parent c31c0b65f71649d69a6bc268b558b40eaa646549 class file path retrieval diff -r c31c0b65f716 -r aa022eaf1569 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java --- 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(); } diff -r c31c0b65f716 -r aa022eaf1569 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java --- 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(); + } } diff -r c31c0b65f716 -r aa022eaf1569 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java --- 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; + } }