Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 361390

Summary: Framework should ensure weaving hooks are presented with byte code in a class cache environment
Product: [Eclipse Project] Equinox Reporter: Matthew Sykes <sykesm.oss>
Component: FrameworkAssignee: Thomas Watson <tjwatson>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: tjwatson
Version: unspecified   
Target Milestone: Juno M4   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 365610    
Attachments:
Description Flags
Possible fix none

Description Matthew Sykes CLA 2011-10-19 08:57:44 EDT
Build Identifier: 3.7.0.v20110613

When working with Apache Aries in an environment running on an IBM J9 JVM, the 'class data sharing' adapter for eclipse is returning a shared class cache token to the framework out of a class loading hook.  The token is then getting passed to the OSGi weaving hooks where the weavers are falling because the class bytes are invalid.

Perhaps there should be a mechanism where the framework attempts to verify that the byte code returned from load hook has a proper byte code magic of 'CAFEBABE' before passing it to the weaving hooks?


Reproducible: Always

Steps to Reproduce:
1. Run equinox on an IBM JDK with the CDS framework extension
2. Enable a weaving hook
3. Note that the weaving hook does not get class bytes by the shared class cache token
Comment 1 Thomas Watson CLA 2011-10-25 13:34:37 EDT
Created attachment 205941 [details]
Possible fix

Here is a possible fix that ensures the weaving hooks get the actual bytes of the real .class file.  This patch assumes that BundleEntry.getInputStream() will always return the actual bytes of the real .class file.  Where getBytes() returns the byte[] to the magic share classes key to be used when defining a class that is a shared class.

The patch detects that the value returned by BundleEntry.getBytes is not a valid class file and will get the real bytes from BundleEntry.getInputStream().