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

Bug 487806

Summary: [gradle] Validation fails with gradle
Product: [Tools] Xtend Reporter: Roland Spatzenegger <c>
Component: CoreAssignee: Project Inbox <xtend-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: christian.dietrich.opensource
Version: 2.9.1Keywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard: v2.11

Description Roland Spatzenegger CLA 2016-02-15 02:50:13 EST
If I run ./gradlew build I get the following error:

ERROR:The method or field id is undefined for the type Object (file:.../xtend-error/src/test/BoardUpdateCommandProcessor.xtend line : 6 column : 42)

The failing code is:
 new(ClientGame game) {
 var player = game.players.findFirst[it.id == 343]

If I remove the Exception from line 27 in Game.java:
void addPlayer(P player) throws BaseException;

gradle builds the project without error. In Eclipse Mars I get no error.

The source code can be found at: https://github.com/CymricNPG/xtend-error 

The discussion at google: https://groups.google.com/forum/#!topic/xtend-lang/lYBLFGCUlM8



Two more observations:
- If the Exception is removed and add again, the build works (except a full clean is done, by removing all temp data)
- If the gradle classpath points to the classes build by Eclipse it works without an error.
Comment 1 Christian Dietrich CLA 2016-09-16 04:43:14 EDT
still and issue with 2.11
Comment 2 Christian Dietrich CLA 2016-09-16 05:28:15 EDT
here is a reproducing unit test (XtendIncrementalBuilderTest)



@Test def void testXXX() {
	val buildRequest = newBuildRequest [
		dirtyFiles = #[
			'src/test/BaseException.java' - '''
			package test;
			
			public class BaseException extends java.lang.Exception {
				private static final long serialVersionUID = 1L;
				public BaseException() {
					super();
				}
			}
			''',
			'src/test/ClientGame.java' - '''
			package test;
			
			public interface ClientGame extends Game<ClientPlayer> {
			
			}''',
			'src/test/ClientPlayer.java' - '''
			package test;
			
			public interface ClientPlayer extends Player {
			
			}''',
			'src/test/Game.java' - '''
			package test;
			
			import java.util.Collection;
			
			public interface Game<P extends Player> extends IDElement {
			
				Collection<P> getPlayers();
			
				void addPlayer(P player) throws BaseException;
			
			}''',
			'src/test/IDElement.java' - '''
			package test;
			
			public interface IDElement {
			
				public int getId();
			}''',
			'src/test/Player.java' - '''
			package test;
			
			public interface Player extends IDElement {
			
			}''',
			'src/test/BoardUpdateCommandProcessor.xtend' - '''
			package test
			
			class BoardUpdateCommandProcessor  {
			
				new(ClientGame game) {
					var player = game.players.findFirst[it.id == 343]
					player = null
				}
			
			}'''
		]
	]
	build(buildRequest)
	assertTrue(issues.toString, issues.isEmpty)
}
Comment 3 Christian Dietrich CLA 2016-09-16 07:16:18 EDT
here is the exception from jdt that got lost inside
the JvmTypesBuilder stuff 

COMPILED type(s)	
	 - test/Game
1 PROBLEM(s) detected 
	 - Pb(320) No exception of type BaseException can be thrown; an exception type must be a subclass of Throwable
Comment 4 Christian Dietrich CLA 2017-02-19 06:02:32 EST
can no longer be reproduced with final Xtext 2.11