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

  • SEARCH
  • Home
  • 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 567671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:06:29+00:00 2026-05-13T13:06:29+00:00

For example, I use a method Measure.doubleValue(Unit<?> unit) which returns the double value of

  • 0

For example, I use a method Measure.doubleValue(Unit<?> unit) which returns the double value of a measurement, expressed in the specified Unit. If I pass a Unit<?> variable to it, I get the still very cryptic (to me) error message:

The method
doubleValue(Unit<capture#27-of ?>) in
the type Measurable<capture#27-of ?>
is not applicable for the arguments
(Unit<capture#28-of ?>)

I would appreciate if someone could explain what that #27-of ? (or any other number) means, and if there is an elegant way to get rid of this. Thus far, I remove the <?> and set the calling method @SuppressWarnings("unchecked") (so I pass an unchecked Unit instead of a Unit<?>) and everything works as desired, but I’m just curious about this, and I feel like suppressing warnings is not a good practice (isn’t it a little like empty catch blocks?).

Thanks!

Edit: Adding some code.

(I’m sorry, this is quite long, but it explains in details what I’m stuck on.)

I am using JSR-275 version 0.9.4 (most recent).

So… If I write this (very dumb example):

Measure measure = Measure.valueOf("3 m");
measure = Measure.valueOf(measure.doubleValue(Unit.valueOf("km")), Unit.valueOf("km"));
System.out.println(measure);

It works and prints “0.0030 km”. But I get warning “Measure is a raw type. References to generic type Measure<Q> should be parameterized” over the first Measure occurrence and warning “Type safety: The method doubleValue(Unit) belongs to the raw type Measurable. References to generic type Measurable<Q> should be parameterized” over measure.doubleValue(Unit.valueOf("km")).

Seeing these warnings, I thought I could adjust this way (first line only):

Measure<Length> measure = Measure.valueOf("3 m");

And then I get error message on right part of assignation “Type mismatch: cannot convert from Measure<capture#1-of ?> to Measure<Length>“. It (Eclipse) offers me to cast the right part to (Measure&lt;Length>). But then I get warning message over the right part “Type safety: Unchecked cast from Measure<capture#1-of ?> to Measure<Length>“. Fix suggested: @SuppressWarnings which I would prefer to avoid (for paranoid reasons I guess).

So, I step back to Measure measure = Measure.valueOf("3 m"); and try to give wildcard to Measure, as obviously, it doesn’t know what “3 m” means at this moment. It could be a Length, but also a Mass or a Time. So I get:

Measure<?> measure = Measure.valueOf("3 m");

And no warning or error on this line; fantastic. But, on the second line:

measure = Measure.valueOf(measure.doubleValue(Unit.valueOf("km")), Unit.valueOf("km"));

I get and error message for doubleValue: “The method doubleValue(Unit<capture#3-of ?>) in the type Measurable<capture#3-of ?> is not applicable for the arguments (Unit<capture#4-of ?>)“. It suggests to cast Unit.valueOf("km") as a (Unit<?>). Fine. Now I get error message at the exact same location: “The method doubleValue(Unit<capture#3-of ?>) in the type Measurable<capture#3-of ?> is not applicable for the arguments (Unit<capture#5-of ?>)“. Notice that the numbers have changed, so that’s not the exact same parameters, but a similar reason. Then it does the exact same suggestion which leads to no change whatsoever in the code, since it has already been done.

So that’s what is bugging me. The only way to get it working seems to @SuppressWarnings or just ignore them. Isn’t it strange?

  • 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-13T13:06:29+00:00Added an answer on May 13, 2026 at 1:06 pm

    Does the measure class look something like this?

    class Measure<T> {
    
      double doubleValue(Unit<T> unit) {
        ...
      }
    
    }
    

    In that case, have a reference type of Measure<?> doesn’t mean that you are allowed to pass any type of Unit to the doubleValue method. Rather, it means that the Measure instance has an unknown generic type, and it isn’t safe to pass a Unit to its doubleValue method because the compiler cannot ensure that the types are compatible.

    A wildcard does not mean “any type”; it means “unknown type”.


    Update:

    The valueOf(CharSequence) returns an unknown type of Measure—a Measure<?>. To convert this safely to the type of Measure you expect, you must use the Measure.asType() method. Likewise with the target Unit, created by the Unit.valueOf(CharSequence) method.

    Measure<?> unknownMeasure = valueOf("3 m");
    Unit<?> unknownUnit = Unit.valueOf("km");
    Measure<Length> length = unknownMeasure.asType(Length.class);
    Unit<Length> kilometer = unknownUnit.asType(Length.class);
    length.doubleValue(kilometer);
    

    Look at the examples in the Measure class documentation. They will provide some additional depth.

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

Sidebar

Ask A Question

Stats

  • Questions 291k
  • Answers 291k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I found the problem, it wasn't the cross-thread operation persay.… May 13, 2026 at 6:04 pm
  • Editorial Team
    Editorial Team added an answer If you know C, PHP should come naturally. It's also:… May 13, 2026 at 6:04 pm
  • Editorial Team
    Editorial Team added an answer finally i have discovered the problem there was more than… May 13, 2026 at 6:04 pm

Related Questions

I am working on a VB6 application that uses an ADODB.Recordset object to dump
I was modifying an overridden method of a subclass. In order to determine the
I'm running a Solaris server to serve PHP through Apache. What tools can I
Before I ask my questions, this is from Apple's documentation re: how to determine
I have an algorithm of which I'm using System.Diagonstics to time - via the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.