Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Model: getValue() unnecessary #6443

Closed
wants to merge 1 commit into from

Conversation

davidgraeff
Copy link
Contributor

Every time I setup a new eclipse IDE environment I get errors about the not existing getValue() method.
Does someone else encounter this phenomenon?

FYI: It is a fresh installation via eclipse installer and reproducible.

Signed-off-by: David Graeff [email protected]

Signed-off-by: David Graeff <[email protected]>
@maggu2810
Copy link
Contributor

Travis is not happy about that change.
I wonder why it is working on your machine. Have you regenerate the models after your change and rebuild the consumer bundles?

[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:1.2.0:compile (default-compile) on project org.eclipse.smarthome.model.rule.runtime: Compilation failure: Compilation failure: 
[ERROR] /home/travis/build/eclipse/smarthome/bundles/model/org.eclipse.smarthome.model.rule.runtime/src/org/eclipse/smarthome/model/rule/runtime/internal/engine/RuleTriggerManager.java:[301] 
[ERROR] 	triggerStateString = ut.getState() != null ? ut.getState() : null;
[ERROR] 	                                             ^^^^^^^^^^^^^
[ERROR] Type mismatch: cannot convert from ValidState to String
[ERROR] /home/travis/build/eclipse/smarthome/bundles/model/org.eclipse.smarthome.model.rule.runtime/src/org/eclipse/smarthome/model/rule/runtime/internal/engine/RuleTriggerManager.java:[308] 
[ERROR] 	triggerStateString = gmut.getState() != null ? gmut.getState() : null;
[ERROR] 	                                               ^^^^^^^^^^^^^^^
[ERROR] Type mismatch: cannot convert from ValidState to String
[ERROR] /home/travis/build/eclipse/smarthome/bundles/model/org.eclipse.smarthome.model.rule.runtime/src/org/eclipse/smarthome/model/rule/runtime/internal/engine/RuleTriggerManager.java:[336] 
[ERROR] 	triggerOldStateString = ct.getOldState() != null ? ct.getOldState() : null;
[ERROR] 	                                                   ^^^^^^^^^^^^^^^^
[ERROR] Type mismatch: cannot convert from ValidState to String
[ERROR] /home/travis/build/eclipse/smarthome/bundles/model/org.eclipse.smarthome.model.rule.runtime/src/org/eclipse/smarthome/model/rule/runtime/internal/engine/RuleTriggerManager.java:[337] 
[ERROR] 	triggerNewStateString = ct.getNewState() != null ? ct.getNewState() : null;
[ERROR] 	                                                   ^^^^^^^^^^^^^^^^
[ERROR] Type mismatch: cannot convert from ValidState to String
[ERROR] /home/travis/build/eclipse/smarthome/bundles/model/org.eclipse.smarthome.model.rule.runtime/src/org/eclipse/smarthome/model/rule/runtime/internal/engine/RuleTriggerManager.java:[344] 
[ERROR] 	triggerOldStateString = gmct.getOldState() != null ? gmct.getOldState() : null;
[ERROR] 	                                                     ^^^^^^^^^^^^^^^^^^
[ERROR] Type mismatch: cannot convert from ValidState to String
[ERROR] /home/travis/build/eclipse/smarthome/bundles/model/org.eclipse.smarthome.model.rule.runtime/src/org/eclipse/smarthome/model/rule/runtime/internal/engine/RuleTriggerManager.java:[345] 
[ERROR] 	triggerNewStateString = gmct.getNewState() != null ? gmct.getNewState() : null;
[ERROR] 	                                                     ^^^^^^^^^^^^^^^^^^
[ERROR] Type mismatch: cannot convert from ValidState to String
[ERROR] /home/travis/build/eclipse/smarthome/bundles/model/org.eclipse.smarthome.model.rule.runtime/src/org/eclipse/smarthome/model/rule/runtime/internal/engine/RuleTriggerManager.java:[378] 
[ERROR] 	triggerCommandString = ct.getCommand() != null ? ct.getCommand() : null;
[ERROR] 	                                                 ^^^^^^^^^^^^^^^
[ERROR] Type mismatch: cannot convert from ValidCommand to String
[ERROR] /home/travis/build/eclipse/smarthome/bundles/model/org.eclipse.smarthome.model.rule.runtime/src/org/eclipse/smarthome/model/rule/runtime/internal/engine/RuleTriggerManager.java:[385] 
[ERROR] 	triggerCommandString = gmct.getCommand() != null ? gmct.getCommand() : null;
[ERROR] 	                                                   ^^^^^^^^^^^^^^^^^

@davidgraeff
Copy link
Contributor Author

davidgraeff commented Nov 3, 2018

I wasn't necessarily expecting it to work, I was waiting for the travis results.

Maybe a mismatch between the eclipse emf and maven emf version, and getValue() is not generated on eclipse? I have no idea. But I do have this problem since a few versions on multiple machines.

@kaikreuzer
Copy link
Contributor

I setup a new eclipse IDE environment

Are you using the official ESH IDE setup and choose a recent a Java IDE as the basis for it in the first step?
I just did a fresh install yesterday and everything compiles and works nicely.

@davidgraeff
Copy link
Contributor Author

Might be fedoras system-installed eclipse fault. I'll test in a VM and open an issue if necessary

@davidgraeff davidgraeff closed this Nov 3, 2018
@davidgraeff
Copy link
Contributor Author

davidgraeff commented Nov 5, 2018

This just after using the official ESH IDE setup, but with a system eclipse installed.
Is xtext generating wrong code here?

The consuming code looks like this:

EventEmittedTrigger et = (EventEmittedTrigger) t;
et.getTrigger().getValue().equals(event)

And the generated code looks like this:

/**
 * generated by Xtext 2.12.0
 */
package org.eclipse.smarthome.model.rule.rules;


/**
 * <!-- begin-user-doc -->
 * A representation of the model object '<em><b>Event Emitted Trigger</b></em>'.
 * <!-- end-user-doc -->
 *
 * <p>
 * The following features are supported:
 * </p>
 * <ul>
 *   <li>{@link org.eclipse.smarthome.model.rule.rules.EventEmittedTrigger#getChannel <em>Channel</em>}</li>
 *   <li>{@link org.eclipse.smarthome.model.rule.rules.EventEmittedTrigger#getTrigger <em>Trigger</em>}</li>
 * </ul>
 *
 * @see org.eclipse.smarthome.model.rule.rules.RulesPackage#getEventEmittedTrigger()
 * @model
 * @generated
 */
public interface EventEmittedTrigger extends EventTrigger
{
  /**
   * Returns the value of the '<em><b>Channel</b></em>' attribute.
   * <!-- begin-user-doc -->
   * <p>
   * If the meaning of the '<em>Channel</em>' attribute isn't clear,
   * there really should be more of a description here...
   * </p>
   * <!-- end-user-doc -->
   * @return the value of the '<em>Channel</em>' attribute.
   * @see #setChannel(String)
   * @see org.eclipse.smarthome.model.rule.rules.RulesPackage#getEventEmittedTrigger_Channel()
   * @model
   * @generated
   */
  String getChannel();

  /**
   * Sets the value of the '{@link org.eclipse.smarthome.model.rule.rules.EventEmittedTrigger#getChannel <em>Channel</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @param value the new value of the '<em>Channel</em>' attribute.
   * @see #getChannel()
   * @generated
   */
  void setChannel(String value);

  /**
   * Returns the value of the '<em><b>Trigger</b></em>' attribute.
   * <!-- begin-user-doc -->
   * <p>
   * If the meaning of the '<em>Trigger</em>' attribute isn't clear,
   * there really should be more of a description here...
   * </p>
   * <!-- end-user-doc -->
   * @return the value of the '<em>Trigger</em>' attribute.
   * @see #setTrigger(String)
   * @see org.eclipse.smarthome.model.rule.rules.RulesPackage#getEventEmittedTrigger_Trigger()
   * @model
   * @generated
   */
  String getTrigger();

  /**
   * Sets the value of the '{@link org.eclipse.smarthome.model.rule.rules.EventEmittedTrigger#getTrigger <em>Trigger</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @param value the new value of the '<em>Trigger</em>' attribute.
   * @see #getTrigger()
   * @generated
   */
  void setTrigger(String value);

} // EventEmittedTrigger

Maven gives me "AbstractClassMirror - resource is empty: java:/Objects/java.lang.Object".

Ah I just found eclipse/xtext-core#702 (xtext < 2.14 not compatible to Java 9+). A new Fedora installation has Java 11 installed.

@maggu2810
Copy link
Contributor

Hi,
can you please explain how you are using the official ESH IDE setup with a system wide installed eclipse?
Do you install the Eclipse IDE by the Eclipse Installer or by your Fedora's package manager?
If you are not using the Eclipse Installer, then you don't use the official IDE setup.
If you are using the Eclipse Installer for a system wide installation (so e.g. in /opt and the installer started as root) then I would assume you will run into permission failures while writing into the eclipse installation folder as an unprivileged user.

@davidgraeff
Copy link
Contributor Author

I'm sorry I have expressed myself incorrect. What I mean is that there is a system wide eclipse installation as well, next to the oompf one. That fact is important to see this error. But that can also just be because fedora is installing java 11 as dependency for eclipse and not me installing java 8 from the repos before executing oomph.

@maggu2810
Copy link
Contributor

The additional Eclipse installation should not matter (if the remaining setup is done well).
Using Java 11 will not work AFAIK as Xtext 2.14 does not work with Java 11.
I would suggest to use Java 8 for ESH for now.

Test the following step:

  • Keep the system Eclipse installation
  • Keep your system Java 11 environment as it is
  • Change the Java VM (+JDK) to 8
  • Start the Eclipse Installer
  • On the first dialog (advanced mode) you can select "Java 1.8 + VM". Check that a Java 1.8 installation is selected
  • Follow as steps as usual
  • After all is done you could also check the eclipse.ini that the Java 1.8 JRE is used to execute the Eclipse IDE
  • Check in the Eclipse IDE preferences that Java 1.8 is selected as the appropriated execution environment

@davidgraeff
Copy link
Contributor Author

@maggu2810 That was the solution. Java 8 has to be selected during the installation. How the missing java 11 support manifests itself is not beginner friendly of course, now that java 11 is the default installation.

I also noted, that the initial setup (with java 8) failed to build the models correctly on my system. I had to manually execute "Generate all models" of the org.eclipse.smarthome.model.codegen bundle.

@maggu2810
Copy link
Contributor

That was the solution. Java 8 has to be selected during the installation.

The setup instructions state "Oracle JDK 8" as a pre-requisite but misses that it should be selected in "Java 1.8 + VM".
https://github.com/eclipse/smarthome/blob/master/docs/documentation/development/ide.md

Would you like to add this information to the documentation?

now that java 11 is the default installation.

The default installation on your Fedora distribution. 😉
I know a lot of distribution that did not moved to Java 11 yet.

I also noted, that the initial setup (with java 8) failed to build the models correctly on my system.

Hm, the latest setup file will run "mvn clean install" as a setup task and this "should" succeed.
Are you sure that the Maven build has been finished?
Does it fail?

@htreu
Copy link
Contributor

htreu commented Nov 6, 2018

Are you sure that the Maven build has been finished?
Does it fail?

According to my (until now undocumented) test it should fail on Java 11:

  • tycho is not yet ready, with tycho-1.3.0-SNAPSHOT the code eventually compiles
  • the SAT plugin needs extra dependencies for javax.annotation, javax.xml.bind and other packages which are now removed in the Java 11 JDK.
  • Unit tests can not be run because mockito, byte-buddy and objenesis are not compatible yet.

I'm going to document all this in detail in #4369.

@davidgraeff
Copy link
Contributor Author

Hm, how about a very early warning in the maven process that not-java-8 is being used. At least until everything works with the current LTS? ^^

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants