Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. jstring -> type name / unexpected expression
Forum Updated to NodeBB v4.3 + New Features

jstring -> type name / unexpected expression

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 404 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Flaming MoeF Offline
    Flaming MoeF Offline
    Flaming Moe
    wrote on last edited by
    #1

    Hello there,

    am trying to call a static Java method which takes a string as argument.

    QJniObject string1 = QJniObject::fromString(song);
        QJniObject::callStaticMethod<void>(
                        "org/qtproject/example/androidnotifier/MusicPlayer",
                        "play",
                        "(Ljava/lang/String;)I" ,
                        string1.object()<jstring>());
    

    I´m getting the error "unexpected type name 'jstring': expected expression" and can´t figure out, if I´m missing to include a library or something else.

    Has someone an idea?

    A lovely day for a ̶g̶̶u̶̶i̶̶n̶̶n̶̶e̶̶s̶ DUFF^^

    C 1 Reply Last reply
    0
    • Flaming MoeF Flaming Moe

      Hello there,

      am trying to call a static Java method which takes a string as argument.

      QJniObject string1 = QJniObject::fromString(song);
          QJniObject::callStaticMethod<void>(
                          "org/qtproject/example/androidnotifier/MusicPlayer",
                          "play",
                          "(Ljava/lang/String;)I" ,
                          string1.object()<jstring>());
      

      I´m getting the error "unexpected type name 'jstring': expected expression" and can´t figure out, if I´m missing to include a library or something else.

      Has someone an idea?

      C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      I think the last line is a little too parentheses-heavy:

      QJniObject string1 = QJniObject::fromString(song);
      QJniObject::callStaticMethod<void>(
                        "org/qtproject/example/androidnotifier/MusicPlayer",
                        "play",
                        "(Ljava/lang/String;)I" ,
                        string1.object<jstring>());
      
      Flaming MoeF 1 Reply Last reply
      0
      • C ChrisW67

        I think the last line is a little too parentheses-heavy:

        QJniObject string1 = QJniObject::fromString(song);
        QJniObject::callStaticMethod<void>(
                          "org/qtproject/example/androidnotifier/MusicPlayer",
                          "play",
                          "(Ljava/lang/String;)I" ,
                          string1.object<jstring>());
        
        Flaming MoeF Offline
        Flaming MoeF Offline
        Flaming Moe
        wrote on last edited by Flaming Moe
        #3

        @ChrisW67
        There is one thing i´m defenetly doing wrong I see now - the 'I' behind the
        (Ljava/lang/String;)
        is wrong, since I call a void-return method.

        QJniObject string1 = QJniObject::fromString(song);
            QJniObject::callStaticMethod<void>(
                            "org/qtproject/example/androidnotifier/MusicPlayer",
                            "play",
                            "(Ljava/lang/String;)I" ,
                            string1.object()<jstring>());
        

        May be there is a flaw in the example .
        In the c-code part of the following is a comma after the method name "fromNumber"

        // C++ code
        QJniObject stringNumber = QJniObject::callStaticObjectMethod("org/qtproject/qt/TestClass",
                                                                     "fromNumber",
                                                                     "(I)Ljava/lang/String;", 10);
        

        while here isn´t a comma after "stringArray"

        // C++ code
        QJniObject string1 = QJniObject::fromString("String1");
        QJniObject string2 = QJniObject::fromString("String2");
        QJniObject stringArray = QJniObject::callStaticObjectMethod<jstringArray>(
                                                                    "org/qtproject/qt/TestClass",
                                                                    "stringArray"
                                                                    string1.object<jstring>(),
                                                                    string2.object<jstring>());
        

        A lovely day for a ̶g̶̶u̶̶i̶̶n̶̶n̶̶e̶̶s̶ DUFF^^

        C 1 Reply Last reply
        0
        • Flaming MoeF Flaming Moe

          @ChrisW67
          There is one thing i´m defenetly doing wrong I see now - the 'I' behind the
          (Ljava/lang/String;)
          is wrong, since I call a void-return method.

          QJniObject string1 = QJniObject::fromString(song);
              QJniObject::callStaticMethod<void>(
                              "org/qtproject/example/androidnotifier/MusicPlayer",
                              "play",
                              "(Ljava/lang/String;)I" ,
                              string1.object()<jstring>());
          

          May be there is a flaw in the example .
          In the c-code part of the following is a comma after the method name "fromNumber"

          // C++ code
          QJniObject stringNumber = QJniObject::callStaticObjectMethod("org/qtproject/qt/TestClass",
                                                                       "fromNumber",
                                                                       "(I)Ljava/lang/String;", 10);
          

          while here isn´t a comma after "stringArray"

          // C++ code
          QJniObject string1 = QJniObject::fromString("String1");
          QJniObject string2 = QJniObject::fromString("String2");
          QJniObject stringArray = QJniObject::callStaticObjectMethod<jstringArray>(
                                                                      "org/qtproject/qt/TestClass",
                                                                      "stringArray"
                                                                      string1.object<jstring>(),
                                                                      string2.object<jstring>());
          
          C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #4

          @Flaming-Moe Yes, that is a missing comma in the documentation. Feel free to raise a bug if you cannot find it already reported.

          Flaming MoeF 1 Reply Last reply
          0
          • Flaming MoeF Flaming Moe has marked this topic as solved on
          • C ChrisW67

            @Flaming-Moe Yes, that is a missing comma in the documentation. Feel free to raise a bug if you cannot find it already reported.

            Flaming MoeF Offline
            Flaming MoeF Offline
            Flaming Moe
            wrote on last edited by
            #5

            @ChrisW67 Even after your former post I haven´t noticed the wrong paranthesis after my ".object" until yesterday evening after staring at goats for a loooong time

            A lovely day for a ̶g̶̶u̶̶i̶̶n̶̶n̶̶e̶̶s̶ DUFF^^

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved