The Artima Developer Community
Sponsored Link

Java Buzz Forum
SourceDir should be a standard class attribute

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Vlad Roubtsov

Posts: 20
Nickname: vladr
Registered: May, 2003

Vlad Roubtsov is a Java Q&A columnist for JavaWorld
SourceDir should be a standard class attribute Posted: Jul 29, 2003 3:53 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Vlad Roubtsov.
Original Post: SourceDir should be a standard class attribute
Feed Title: Java Curiosity Shop
Feed URL: http://www.blog-city.com/bc/
Feed Description: Java esoterics: things from "don't try this at home" category
Latest Java Buzz Posts
Latest Java Buzz Posts by Vlad Roubtsov
Latest Posts From Java Curiosity Shop

Advertisement
Another relatively useless bit of Java trivia: I chanced to run my javap-like tool on some really old Java code on my machine and discovered another undocumented .class attribute that MS jvc compiler used to emit: SourceDir [generic]: name @3, length = 8 Because every attribute has a standard 6 byte header it is pretty obvious that SourceDir contains a u2 pointer to a CONSTANT_Utf8 entry that is the directory containing the source file at the time it was compiled. Browsing through constant pool entries confirms this: [340] CONSTANT_Utf8: D:\code\Java\…more dir segments…\ Together with the [standard] SourceFile attribute this provides complete information on the source file location. Pretty useful for tools like debuggers and coverage analyzers, if you ask me. Sun’s compilers should emit the same attribute.

Read: SourceDir should be a standard class attribute

Topic: More Coding Aphorisms Previous Topic   Next Topic Topic: .NET gaining on Java, developers take note

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use