This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 178336 - Compile on Save utility class to work with bytecode without running it
Summary: Compile on Save utility class to work with bytecode without running it
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 6.x
Hardware: All All
: P2 normal (vote)
Assignee: Svata Dedic
URL:
Keywords: API
Depends on:
Blocks:
 
Reported: 2009-12-08 19:54 UTC by Jesse Glick
Modified: 2013-09-02 14:23 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2009-12-08 19:54:24 UTC
BuildArtifactMapper has some capabilities which could be useful for CoS if all you need to do is run the code using JavaRunner. However if you are interested in doing something else with the code, such as static analysis (*), BAM cannot be used reliably:

1. It will not work if the project does not have CoS enabled, even though the IDE still maintains internal bytecode in this case.

2. It does not work if the project is not currently synchronized, according to details of when a full build was last run and so on.

We need something that will give you reliable access to an up-to-date copy of the Java indexer cache (with *.sig translated to *.class) for any source root. For SQE, I have a prototype which calls into java.source using reflection and accomplishes this:

https://hg.kenai.com/hg/sqe~trunk/raw-file/nb68/core.java/src/org/nbheaven/sqe/core/java/utils/CompileOnSaveHelper.java

It only deals with one classpath entry at a time, which I think is OK (but we could consider passing in an entire ClassPath object). You can either pass a source root, or a (binary) classpath entry which will be matched to a source root if appropriate (preferSources). You get back a usable Java classpath entry; this could be the public output directory, if both #1 and #2 above in fact hold; otherwise it will be a copy of the indexer cache.

Currently there is no event firing support (such as ArtifactsUpdated), since FileUtil.addRecursiveListener does not work on indexer cache, but of course if this were implemented in java.source the problem would be solved since BuildArtifactMapperImpl.classCacheUpdated would notify the appropriate listeners directly.

(*) E.g.: http://kenai.com/jira/browse/SQE-9