返される実際のタイプはcoldfusion.image.Imageです。java.lang.Classがほぼ完成しました。これは、coldfusion.image.Imageが何であるかを表すjava.lang.Classの実際のインスタンスです。私たちが扱っているクラスの種類を見つけるには、java.lang.Classにいくつか質問する必要があります。
<cfdump var="#ImageNew()#"/>
<cfdump var="#GetMetaData(ImageNew())#"/>
<cfdump var="#GetMetaData(ImageNew()).getCanonicalName()#"/>
<cfdump var="#GetMetaData(ImageNew()).getName()#"/>
<cfdump var="#GetMetaData(ImageNew()).getSimpleName()#"/>
そこで、返ってきた回答に基づいて、いくつかのシナリオを試しました。
<cffunction name="GetImage" access="private" output="false" returntype="Struct">
<cfreturn ImageNew()/>
</cffunction>
<cffunction name="GetImage" access="private" output="false" returntype="coldfusion.image.Image">
<cfreturn ImageNew()/>
</cffunction>
<cffunction name="GetImage" access="private" output="false" returntype="Image">
<cfreturn ImageNew()/>
</cffunction>
ただし、実際には、実行時にそれらすべてが失敗しました。
The value returned from the GetImage function is not of type Struct.
The value returned from the GetImage function is not of type coldfusion.image.Image.
The value returned from the GetImage function is not of type Image.
それらが失敗した理由は、ColdFusionがcoldfusion.image名前空間にインポートせずにコードをコンパイルするためだと思います。確かに、それはImageNew()でそれを利用しますが、それはおそらくcoldfusion.globalFunctionsのようなものにインポートしているだけです。したがって、私のCFCはcoldfusion.image.Imageが実際に何であるかを知りません。
私はあなたが使用することに固執していると思いますreturntype="Any"
-ごめんなさい。私は自分のタイプを開発のために強く保ち、それから本番環境でタイプチェックをオフにするのが好きなので、そうですね。