getPackageToPackageInfoMappings().put(packageName, packageInfo);
}
String name = componentClass.getName();
Type componentType = Type.getType(L + componentClass.getName().replace(DOT_CHR, SLASH_CHR) + SEMI_COLON);
String componentTypeInternalName = null;
if (name.equals("[B")) {
name = "byteArray";
componentTypeInternalName = componentType.getInternalName();
} else if (name.equals("[Ljava.lang.Byte;")) {
name = "ByteArray";
componentTypeInternalName = componentType.getInternalName() + SEMI_COLON;
} else {
componentTypeInternalName = L + componentType.getInternalName() + SEMI_COLON;
}
int beginIndex = name.lastIndexOf(DOT_CHR) + 1;
name = name.substring(beginIndex);
int dollarIndex = name.indexOf(DOLLAR_SIGN_CHR);
if (dollarIndex > -1) {
name = name.substring(dollarIndex + 1);
}
String collectionClassRawName = collectionClass.getRawName();
String collectionClassShortName = collectionClassRawName.substring(collectionClassRawName.lastIndexOf(DOT_CHR) + 1);
String suggestedClassName = collectionClassShortName + "Of" + name;
String qualifiedClassName = packageName + DOT_CHR + suggestedClassName;
qualifiedClassName = getNextAvailableClassName(qualifiedClassName);
Type collectionType = Type.getType(L + collectionClassRawName.replace(DOT_CHR, SLASH_CHR) + SEMI_COLON);
String qualifiedInternalClassName = qualifiedClassName.replace(DOT_CHR, SLASH_CHR);
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
String classSig = "Lorg/eclipse/persistence/internal/jaxb/many/CollectionValue<L" + collectionType.getInternalName() + "<" + componentTypeInternalName + ">;>;";
cw.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, qualifiedInternalClassName, classSig, "org/eclipse/persistence/internal/jaxb/many/CollectionValue", null);
// Write Field: @... public {collectionType} item;
String fieldSig = L + collectionType.getInternalName() + "<" + componentTypeInternalName + ">;";
FieldVisitor fv = cw.visitField(Opcodes.ACC_PUBLIC, ITEM, L + collectionType.getInternalName() + SEMI_COLON, fieldSig, null);
if (typeMappingInfo != null) {
Annotation[] annotations = getAnnotations(typeMappingInfo);
if (annotations != null) {
for (int i = 0; i < annotations.length; i++) {
Annotation nextAnnotation = annotations[i];
if (nextAnnotation != null && !(nextAnnotation instanceof XmlElement) && !(nextAnnotation instanceof XmlJavaTypeAdapter)) {
String annotationClassName = nextAnnotation.annotationType().getName();
AnnotationVisitor av = fv.visitAnnotation(L + annotationClassName.replace(DOT_CHR, SLASH_CHR) + SEMI_COLON, true);
for (Method next : nextAnnotation.annotationType().getDeclaredMethods()) {
try {
Object nextValue = next.invoke(nextAnnotation, new Object[] {});
if (nextValue instanceof Class) {
Type nextType = Type.getType(L + ((Class) nextValue).getName().replace(DOT_CHR, SLASH_CHR) + SEMI_COLON);
nextValue = nextType;
}
av.visit(next.getName(), nextValue);
} catch (InvocationTargetException ex) {
// ignore the invocation target exception here.