This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 250942 - Inspection "Typecast too strong" doesn't recognize necessity of cast for ambiguous method arguments
Summary: Inspection "Typecast too strong" doesn't recognize necessity of cast for ambi...
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.0.2
Hardware: PC Linux
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-05 18:24 UTC by kalle1
Modified: 2015-06-02 14:24 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
example project (2.78 KB, application/x-xz)
2015-03-05 18:24 UTC, kalle1
Details

Note You need to log in before you can comment on or make changes to this bug.
Description kalle1 2015-03-05 18:24:26 UTC
Created attachment 152419 [details]
example project

and thus can cause uncompilable code after refactoring. The example class is 

    package de.richtercloud.unnecessary.call.to.string;

    import com.orientechnologies.common.util.OCallable;
    import com.orientechnologies.orient.core.metadata.schema.OClass;
    import com.tinkerpop.blueprints.Features;
    import com.tinkerpop.blueprints.impls.orient.OrientBaseGraph;
    import com.tinkerpop.blueprints.impls.orient.OrientEdgeType;
    import com.tinkerpop.blueprints.impls.orient.OrientVertexType;

    /**
     * example taken from orientdb's
     * com.tinkerpop.blueprints.impls.orient.OrientBaseGraph
     *
     * @author richter
     */
    public class UnnecessaryCallToString extends OrientBaseGraph {

        public UnnecessaryCallToString(String url) {
            super(url);
        }

        @Override
        public OrientVertexType createVertexType(final String iClassName) {
            makeActive();

            return createVertexType(iClassName, (String) null);
        }

        @Override
        public OrientEdgeType createEdgeType(final String iClassName) {
            makeActive();

            return createEdgeType(iClassName, (String) null);
        }

        @Override
        public OrientEdgeType createEdgeType(final String iClassName, final String iSuperClassName) {
            return createEdgeType(iClassName, iSuperClassName == null ? getEdgeBaseType() : getEdgeType(iSuperClassName));
        }

        @Override
        public OrientEdgeType createEdgeType(final String iClassName, final OClass iSuperClass) {
            return executeOutsideTx(new OCallable<OrientEdgeType, OrientBaseGraph>() {
                @Override
                public OrientEdgeType call(final OrientBaseGraph g) {
                    return new OrientEdgeType(g, getRawGraph().getMetadata().getSchema().createClass(iClassName, iSuperClass));
                }
            }, "create edge type '", iClassName, "' as subclass of '", iSuperClass.getName(), "'");
        }

        @Override
        public Features getFeatures() {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    }

I created and attached a sample maven project (which depends on orientdb - I don't seem to figure out what the cause is and didn't manage to create a project from scratch).
Comment 1 kalle1 2015-03-05 18:26:27 UTC
The cast of `null` to `String` is necessary in both cases and the "Typecast to strong" inspection causes uncompilable source code because the call to `createEdgeType` and `createVertexType` is ambiguous without the casts.
Comment 2 Svata Dedic 2015-06-02 14:24:01 UTC
Should be already fixed in dev version as part of issue #243581