Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 433301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:09:37+00:00 2026-05-12T20:09:37+00:00

I’m trying to get a real equivalent for Java’s public static final in Scala

  • 0

I’m trying to get a real equivalent for Java’s public static final in Scala for using TwiP.

Creating a val in an object doesn’t work for me, because it’s part of a new generated class Example$.class and TwiP can’t access it from class Example.class.

Here’s an example of a Java Class I’m trying to port to Scala:

public static final String[] MY_STRINGS = { "A", "B", "C" };

@Test
public void myTest(@Values("MY_STRINGS") String string) {
  ...
}

But I don’t know how to port the public static final to Scala. If it’s a val in an object like here

@RunWith(classOf[TwiP])
class Foo {

  import Foo.MY_STRINGS

  @Test
  def testTwiP(@Values("MY_STRINGS") value: String): Unit = {
    println("I'm testing value " + value + ".")
  }

}

object Foo {
  val MY_STRINGS = Array("A", "B", "C")
}

I only get the following exception:

net.sf.twip.internal.TwipConfigurationError:
there is no method or field 'MY_STRINGS' named in the @Values annotation of Parameter#1

How can I solve the problem using Scala?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T20:09:38+00:00Added an answer on May 12, 2026 at 8:09 pm

    The following Scala code:

    class Foo{
      import Bar.MY_STRINGS
    }
    object Bar{
      val MY_STRINGS=Array("A","B","C")
    }
    

    Generates the following Java classes:

    public final class Bar extends java.lang.Object{
        public static final java.lang.String[] MY_STRINGS();
        public static final int $tag()       throws java.rmi.RemoteException;
    }
    public final class Bar$ extends java.lang.Object implements scala.ScalaObject{
        public static final Bar$ MODULE$;
        public static {};
        public Bar$();
        public java.lang.String[] MY_STRINGS();
        public int $tag()       throws java.rmi.RemoteException;
    }
    public class Foo extends java.lang.Object implements scala.ScalaObject{
        public Foo();
        public int $tag()       throws java.rmi.RemoteException;
    }
    

    The following Scala code:

    class Foo{
      import Foo.MY_STRINGS
    }
    object Foo{
      val MY_STRINGS=Array("A","B","C")
    }
    

    Generates the following Java classes:

    public class Foo extends java.lang.Object implements scala.ScalaObject{
        public Foo();
        public int $tag()       throws java.rmi.RemoteException;
    }
    public final class Foo$ extends java.lang.Object implements scala.ScalaObject{
        public static final Foo$ MODULE$;
        public static {};
        public Foo$();
        public java.lang.String[] MY_STRINGS();
        public int $tag()       throws java.rmi.RemoteException;
    }
    

    The fact that static members aren’t defined on the class when the object has the same name as the class is Scala Bug #1735 and it’s fixed in Scala 2.8 snapshots.

    So it looks like TwiP isn’t going to work at all unless you either upgrade Scala, or find a way to get TwiP to work with non-Static parameter generation methods.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.