Community
Participate
Working Groups
A NPE raises while creating types. There seems to be a problem with the annotation processing. The member value is null, even though a default is specified. It works with annotations from the javax.annotation package but not with own annotations (maybe a difference between compiled and source?). The NPE raises as it is assumed that the value is never null. java.lang.NullPointerException at org.eclipse.xtext.common.types.access.jdt.JdtBasedTypeFactory.createAnnotationValue(JdtBasedTypeFactory.java:239) at org.eclipse.xtext.common.types.access.jdt.JdtBasedTypeFactory.createAnnotationReference(JdtBasedTypeFactory.java:154) at org.eclipse.xtext.common.types.access.jdt.JdtBasedTypeFactory.createAnnotationValues(JdtBasedTypeFactory.java:136) at org.eclipse.xtext.common.types.access.jdt.JdtBasedTypeFactory.createOperation(JdtBasedTypeFactory.java:529) at org.eclipse.xtext.common.types.access.jdt.JdtBasedTypeFactory.createMethods(JdtBasedTypeFactory.java:314) at org.eclipse.xtext.common.types.access.jdt.JdtBasedTypeFactory.createType(JdtBasedTypeFactory.java:111) at org.eclipse.xtext.common.types.access.jdt.JdtBasedTypeFactory.createType(JdtBasedTypeFactory.java:90) at org.eclipse.xtext.common.types.access.jdt.JdtBasedTypeFactory.createType(JdtBasedTypeFactory.java:1) at org.eclipse.xtext.common.types.access.jdt.JdtTypeMirror.initialize(JdtTypeMirror.java:41) at org.eclipse.xtext.common.types.access.TypeResource.doLoad(TypeResource.java:86) at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1494) at org.eclipse.xtext.common.types.access.TypeResource.load(TypeResource.java:74) at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:255) at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:270) at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:397) at org.eclipse.xtext.common.types.access.jdt.JdtTypeProvider.findTypeByName(JdtTypeProvider.java:62) at org.eclipse.xtext.common.types.xtext.AbstractTypeScope.getContentByName(AbstractTypeScope.java:42)
Please provide the source for the class and and the annotations that are present on the class. Do you try to create the JvmType for the compiled class or for the source class? Does the error occur in the runtime mode, too?
This works for me. Now the type can be created (the annotations are not relevant). if (value == null) { return result; } The default values do not work for the annotations from the own source code. --- package com.xxx.annotations import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Im Gegensatz zu der @Generated aus der JDK kann diese Annotation auch zur Laufzeit ausgewertet werden. */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface Generated { /** Der Name der Resource, aus der diese Datei generiert wurde. */ String source() default ""; } --- @javax.annotation.Generated("something") @com.xxx.annotations.Generated public interface YY {} --- The javax.annotation.Generated has 'String comments() default "";' which works. The com.xxx.annotations.Generated has 'String source() default "";' which does not work.
Pushed fix to master.
This one will tackle to causer for the NPE: https://bugs.eclipse.org/bugs/show_bug.cgi?id=334943
As stated in comment #3, a workaround was pushed to master.
Pushed to Helios maintenance.
Closing all bugs that were set to RESOLVED before Neon.0