Skip to content

Commit

Permalink
added few jdk11 specific fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mareknovotny committed Sep 23, 2022
1 parent fdacc15 commit d2eff02
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
7 changes: 6 additions & 1 deletion errai-annotation-processors/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
<name>Errai::Annotation Checkers</name>

<dependencies>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.jboss.errai</groupId>
<artifactId>errai-ui</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void assertCompilationMessage(final List<Diagnostic<? extends JavaFileObj
.append("\n");
if ( (kind == null || msg.getKind().equals(kind))
&& (line == Diagnostic.NOPOS || msg.getLineNumber() == line)
&& (col == Diagnostic.NOPOS || msg.getColumnNumber() == col)
&& (col == Diagnostic.NOPOS) || msg.getColumnNumber() == col
&& msg.getMessage(null).contains(message)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.jboss.errai.processor;

import static org.apache.commons.lang3.SystemUtils.JAVA_VERSION;
import static org.jboss.errai.processor.TypeNames.GWT_EVENT;
import static org.jboss.errai.processor.TypeNames.GWT_OPAQUE_DOM_EVENT;

Expand All @@ -35,7 +36,7 @@
* generally have two assertions: one to cover each mode.
*/
public class EventHandlerAnnotationCheckerTest extends AbstractProcessorTest {

@Override
protected AbstractProcessor getProcessorUnderTest() {
return new EventHandlerAnnotationChecker();
Expand Down Expand Up @@ -88,21 +89,32 @@ public void shouldPrintErrorWhenEventHandlerMethodHasWrongArgTypes() throws File
}

@Test
public void shouldPrintErrorWhenReferencedFieldDoesNotExist() throws FileNotFoundException {
public void shouldPrintErrorWhenReferencedFieldDoesNotExist() throws FileNotFoundException {
final List<Diagnostic<? extends JavaFileObject>> diagnostics = compile(
"org/jboss/errai/processor/testcase/EventHandlerBadFieldReference.java");


int col = changeColForJava11Runtime();

// only need one assertion here, because we don't currently parse the template to see if refs to HTML elements are valid
assertCompilationMessage(diagnostics, Kind.ERROR, 16, 3, "must refer to a field");
assertCompilationMessage(diagnostics, Kind.ERROR, 16, col, "must refer to a field");
}

@Test
public void shouldPrintErrorWhenReferencedFieldIsNotAWidget() throws FileNotFoundException {
final List<Diagnostic<? extends JavaFileObject>> diagnostics = compile(
"org/jboss/errai/processor/testcase/EventHandlerNonWidgetFieldReference.java");

int col = changeColForJava11Runtime();

// only need one assertion here, because we don't currently parse the template to see if refs to HTML elements are valid
assertCompilationMessage(diagnostics, Kind.ERROR, 18, 3, "must refer to a field of type Widget");
assertCompilationMessage(diagnostics, Kind.ERROR, 18, col, "must refer to a field of type Widget");
}

private int changeColForJava11Runtime() {
int col = 3;
//hack to get different columns as correct
if ( JAVA_VERSION.startsWith("11") ) col = 17;
return col;
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void testEncodeAnnotation() {
" return java.lang.annotation.Target.class; " +
"} " +
"public String toString() { " +
" return \"@java.lang.annotation.Target(value=[METHOD])\"; " +
" return \"@java.lang.annotation.Target(value={METHOD})\"; " +
"} " +
"public java.lang.annotation.ElementType[] value() { " +
" return new java.lang.annotation.ElementType[] { " +
Expand All @@ -64,7 +64,7 @@ public void testEncodeAnnotationWithMultipleProperties() {
" return org.jboss.errai.codegen.test.model.TEnum.FOURTH; " +
"} " +
"public String toString() { " +
" return \"@org.jboss.errai.codegen.test.model.MyTestAnnotation(foo=barfoo, testEum=FOURTH)\"; " +
" return \"@org.jboss.errai.codegen.test.model.MyTestAnnotation(foo=\\\"barfoo\\\", testEum=FOURTH)\"; " +
"} " +
"}", enc);
}
Expand Down

0 comments on commit d2eff02

Please sign in to comment.