Class WovenClassImpl
- All Implemented Interfaces:
Iterable<String>
,Collection<String>
,List<String>
,WovenClass
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]
private final String
private Class
private boolean
private int
private final BundleWiring
Fields inherited from interface org.osgi.framework.hooks.weaving.WovenClass
DEFINE_FAILED, DEFINED, TRANSFORMED, TRANSFORMING, TRANSFORMING_FAILED
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) byte[]
void
boolean
boolean
addAll
(int i, Collection<? extends String> collection) boolean
addAll
(Collection<? extends String> collection) private void
void
clear()
(package private) void
(package private) void
completeDefine
(Class definedClass) (package private) void
completeImports
(List<String> imports) boolean
boolean
containsAll
(Collection<?> collection) get
(int i) Returns the bundle wiring whose class loader will define the woven class.byte[]
getBytes()
Returns the class file bytes to be used to define thenamed
class.Returns the fully qualified name of the class being woven.Class
<?> Returns the class defined by this woven class.Returns the list of dynamic import package descriptions to add to thebundle wiring
for this woven class.Returns the protection domain to which the woven class will be assigned when it is defined.int
getState()
Returns the current state of this woven class.int
boolean
isEmpty()
boolean
Returns whether weaving is complete in this woven class.iterator()
int
listIterator
(int i) remove
(int i) boolean
boolean
removeAll
(Collection<?> collection) boolean
retainAll
(Collection<?> collection) void
setBytes
(byte[] bytes) Set the class file bytes to be used to define thenamed
class.void
setState
(int state) int
size()
subList
(int i, int i1) Object[]
toArray()
<T> T[]
toArray
(T[] ts) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream
Methods inherited from interface java.util.List
equals, hashCode, replaceAll, sort, spliterator
-
Field Details
-
m_className
-
m_wiring
-
m_bytes
private byte[] m_bytes -
m_imports
-
m_definedClass
-
m_isComplete
private boolean m_isComplete -
m_state
private int m_state
-
-
Constructor Details
-
WovenClassImpl
WovenClassImpl(String className, BundleWiring wiring, byte[] bytes)
-
-
Method Details
-
complete
-
completeImports
-
completeDefine
-
getBytes
public byte[] getBytes()Description copied from interface:WovenClass
Returns the class file bytes to be used to define thenamed
class.While in the
WovenClass.TRANSFORMING
state, this method returns a reference to the class files byte array contained in this object. After leaving theWovenClass.TRANSFORMING
state, this woven class can no longer be transformed and a copy of the class file byte array is returned.- Specified by:
getBytes
in interfaceWovenClass
- Returns:
- The bytes to be used to define the
named
class.
-
setBytes
public void setBytes(byte[] bytes) Description copied from interface:WovenClass
Set the class file bytes to be used to define thenamed
class. This method must not be called outside invocations of theweave
method by the framework.While in the
WovenClass.TRANSFORMING
state, this method replaces the reference to the array contained in this object with the specified array. After leaving theWovenClass.TRANSFORMING
state, this woven class can no longer be transformed and this method will throw anIllegalStateException
.- Specified by:
setBytes
in interfaceWovenClass
- Parameters:
bytes
- The new classfile that will be used to define thenamed
class. The specified array is retained by this object and the caller must not modify the specified array.
-
getDynamicImportsInternal
-
getDynamicImports
Description copied from interface:WovenClass
Returns the list of dynamic import package descriptions to add to thebundle wiring
for this woven class. Changes made to the returned list will be visible to laterweaving hooks
called with this object. The returned list must not be modified outside invocations of theweave
method by the framework.After leaving the
WovenClass.TRANSFORMING
state, this woven class can no longer be transformed and the returned list will be unmodifiable.If the Java runtime environment supports permissions, any modification to the returned list requires
AdminPermission[bundle,WEAVE]
. Additionally, any add or set modification requiresPackagePermission[package,IMPORT]
.- Specified by:
getDynamicImports
in interfaceWovenClass
- Returns:
- A list containing zero or more dynamic import package
descriptions to add to the bundle wiring for this woven class.
This list must throw
IllegalArgumentException
if a malformed dynamic import package description is added. - See Also:
-
isWeavingComplete
public boolean isWeavingComplete()Description copied from interface:WovenClass
Returns whether weaving is complete in this woven class. Weaving is complete after the class is defined.- Specified by:
isWeavingComplete
in interfaceWovenClass
- Returns:
true
ifstate
isWovenClass.DEFINED
,WovenClass.TRANSFORMING_FAILED
orWovenClass.DEFINE_FAILED
;false
otherwise.
-
getClassName
Description copied from interface:WovenClass
Returns the fully qualified name of the class being woven.- Specified by:
getClassName
in interfaceWovenClass
- Returns:
- The fully qualified name of the class being woven.
-
getProtectionDomain
Description copied from interface:WovenClass
Returns the protection domain to which the woven class will be assigned when it is defined.- Specified by:
getProtectionDomain
in interfaceWovenClass
- Returns:
- The protection domain to which the woven class will be assigned
when it is defined, or
null
if no protection domain will be assigned.
-
getDefinedClass
Description copied from interface:WovenClass
Returns the class defined by this woven class. During weaving, this method will returnnull
. Once weaving iscomplete
, this method will return the class object if this woven class was used to define the class.- Specified by:
getDefinedClass
in interfaceWovenClass
- Returns:
- The class associated with this woven class, or
null
if weaving is not complete, the class definition failed or this woven class was not used to define the class.
-
getBundleWiring
Description copied from interface:WovenClass
Returns the bundle wiring whose class loader will define the woven class.- Specified by:
getBundleWiring
in interfaceWovenClass
- Returns:
- The bundle wiring whose class loader will define the woven class.
-
size
public int size() -
isEmpty
public boolean isEmpty() -
contains
-
iterator
-
toArray
-
toArray
public <T> T[] toArray(T[] ts) -
add
-
checkImport
-
remove
-
containsAll
- Specified by:
containsAll
in interfaceCollection<String>
- Specified by:
containsAll
in interfaceList<String>
-
addAll
-
addAll
-
removeAll
-
retainAll
-
clear
public void clear() -
get
-
set
-
add
-
remove
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceList<String>
-
listIterator
- Specified by:
listIterator
in interfaceList<String>
-
listIterator
- Specified by:
listIterator
in interfaceList<String>
-
subList
-
_getBytes
byte[] _getBytes() -
getState
public int getState()Description copied from interface:WovenClass
Returns the current state of this woven class.A woven class can be in only one state at any time.
- Specified by:
getState
in interfaceWovenClass
- Returns:
- Either
WovenClass.TRANSFORMING
,WovenClass.TRANSFORMED
,WovenClass.DEFINED
,WovenClass.TRANSFORMING_FAILED
orWovenClass.DEFINE_FAILED
.
-
setState
public void setState(int state)
-