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 824507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:06:37+00:00 2026-05-15T03:06:37+00:00

I have an Java-Annotation that return a double value: @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface DoubleValue

  • 0

I have an Java-Annotation that return a double value:

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface DoubleValue {
  double value();
} 

When i try to attach the annotation to a field in a scala class and the value is negativ like here:

class Test {
  @DoubleValue(-0.05)
  var a = _
}

i get an compiler error with the message: “annotation argument needs to be a constant; found: 0.05.unary_-“. I understood that i need a numerical literal and i looked into the Scala Language Specification and it seems, that the – sign is only used for the exponent but not for the mantissa. Does someone has an idea how i can have a negative value as runtime information using annotations?

Thanks,
Klinke

  • 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-15T03:06:38+00:00Added an answer on May 15, 2026 at 3:06 am

    It appears that this is a bug.

    Until the bug is fixed, you can take advantage of the fact that arithmetic on a constant is a constant and use

    @DoubleValue( 0-0.05 )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Java 1.6.0_25. I have an annotation defined: @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface Resource
I've created simple annotation in Java @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface Column { String columnName();
I have a Java class that contains a list of another class. @Entity public
I have Java Map (out of Strings and Ints) objects that I want to
I have a service class implemented in Java 6 / Spring 3 that needs
I want to implement an intialization mechanism that is annotation-based in Java. Specifically, I
New to spring, we have a whole pile of validators that generate java warnings,
Suppose I have an interface: public interface FooInterface { public void someMethod(); } and
I have the following ApplicationScoped bean package es.caib.gesma.gesman.data; import java.util.List; import javax.annotation.PostConstruct; import javax.ejb.EJB;
I have some old code (pre Java 1.5) that uses classes to implement type

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.