Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    The type java.lang.invoke.VarHandle cannot be resolved. It is indirectly referenced from required .class files.. Seen in latest eclipse 2023-03

    SmartClient Version: v13.0p_2023-04-25/PowerEdition Deployment (built 2023-04-25)

    Eclipse IDE for Enterprise Java and Web Developers (includes Incubating components)

    Version: 2023-03 (4.27.0)
    Build id: 20230309-1520

    We recently updated our source control to the latest GiT release. We were having interaction problems between the standard (i.e. old) eclipse Photon version (2018) and this GiT, so we downloaded the latest eclipse release 2023-03.

    The new eclipse is the ONLY change in this environment.

    We have several apps that we build on SmartClient and each app shares this same error in different code. Here is a code example of the error indicated in eclipse while running from eclipse:

    Code:
    tagField = new MultiComboBoxItem("TagName");
    
    .....
    
    List<String> tagSelectVal = (List<String>)viewState.get("tagSelectItem");
    
    .....
    
    if (tagSelectVal != null) {
               String[] array = tagSelectVal.toArray(new String[tagSelectVal.size()]);
               tagField.setValues((Object[])(array));
      }
    I have removed extraneous ( I believe ) lines of code from this example.

    The error eclipse posts at the line: tagField.setValues((Object[])(array)); is:

    The type java.lang.invoke.VarHandle cannot be resolved. It is indirectly referenced from required .class files

    Another example of the same error in another piece of code in another eclipse project is:

    Code:
    ((MultiComboBoxItem) getItem("Blocks")).setValues(new Object[] {});
    This code is attempting to nullify or clear, the values that are in the "Blocks" key of the MultiComboBoxItem.

    Is this an incompatibility between our standard Java 8 version and the Java version required (?) by eclipse. A Google search indicates eclipse should work with a minimum Java version of eclipse of 5 (?) so version 8 should be good on all released versions of eclipse ? There appears to be a single reference to this issue found here. But the reference seems to not offer a viable solution for us.

    Another form of the question is: are we initializing the MultiComboBoxItem.setValues() api correctly (although seems to work), and that is the code that needs to change?
    void setValues(java.lang.Object... values)


    ?



    #2
    You seem to have be having terrible luck with bizarre Java error messages recently!

    VarHandle is a JDK 9+ class, so, somehow the more recent JDK has infiltrated your project again.

    What we suspect has happened is that some classes were compiled with JDK9+ and so they contain references to JDK9 classes. If you wipe out all of the compiled classes, and perhaps restart Eclipse, that may fix it.

    Comment


      #3
      Thanks for the reply. Stop / restarting eclipse in a new checked out workspace, which has been cleaned, does not resolve the issue.

      However changing ONLY the eclipse version back to 2022-06 DOES make the problem go away. It cleanly compil

      Given that another user sees the same issue with eclipse, ( found here) I think the easiest solution is just to put it down to an eclipse bug. Have you tried 2023-03 release of eclipse yet?

      Comment


        #4
        That's a really weird Eclipse bug. No, we have not tried using that version of Eclipse yet.

        Comment


          #5
          An update.

          We believe we have a workaround for this problem.

          Eclipse version 2023-03 marks that any usage of MultiComboBoxItem.setValues( empty or null array ) or PopupMultiComboBoxItem.setValues( null array) as having the error:

          The type java.lang.invoke.VarHandle cannot be resolved. It is indirectly referenced from required .class files

          However if we re-write code like this:

          Code:
          if(vals != null && vals.length() > 0 && !(vals.trim().equals(""))){
                       editor.getEditor().setValues(vals.split(","));
          }
          to this:

          ​​​​​​​
          Code:
          if(vals != null && vals.length() > 0 && !(vals.trim().equals(""))){
                     ((FormItem)editor.getEditor()).setValue(vals.split(","));
            }
          ​​​​​​​
          the eclipse error goes away, and we think it is equivalent.

          To show how my first posting was re-written:

          Code:
          tagField = new MultiComboBoxItem("TagName");
          .....
          
          List<String> tagSelectVal = (List<String>)viewState.get("tagSelectItem");
          .....
          
          if (tagSelectVal != null) {
          String[] array = tagSelectVal.toArray(new String[tagSelectVal.size()]);
          
          ((FormItem)tagField).setValue((Object[])(array)); }
          
          // no error marked....
          ​​​​​​​
          Do you see a problem with this re-write?

          Comment


            #6
            The underlying code paths for MCBI.setValues(array) and FormItem.setValue(array) are very similar when an Array of Object (Object[]) is passed. The only difference is that MCBI.setValues(array) does "strict" conversion to JavaScript and FormItem.setValue(array) doesn't.

            This just means that in some odd corner cases you may get a Java exception thrown by MCBI.setValues(array) reporting:
            Attempt to convert instance of class [some Java class] to a JavaScript object failed. Object is a member of an Array being converted to JavaScript. Please see the SmartClient documentation of RPCRequest.data for a table of Java types that can be converted automatically.
            whereas FormItem.setValue(array) would silently "convert" it in a way that may or may not be valid.

            If the data you're converting isn't anything exotic, then the difference here is probably nothing to worry about.

            Comment

            Working...
            X