Skip to main content
3-Newcomer
June 4, 2026
Question

Creo OTK Java: why do WSession / WSolid casts fail?

  • June 4, 2026
  • 1 reply
  • 19 views

I’m investigating a Creo OTK Java casting issue in Creo Parametric 12.4.3.0 and would appreciate any confirmation or guidance from others who have seen this. Based on the documentation and shipped Java examples, I expected direct casts such as WSession wSession = (WSession) session, WSolid wSolid = (WSolid) model, and WFeature wFeat = (WFeature) feat to work. However, in controlled tests, the objects returned from ordinary acquisition paths come back as runtime classes like com.ptc.wfc.Implementation.pfcSession$Session, com.ptc.wfc.Implementation.pfcPart$Part, and com.ptc.wfc.Implementation.pfcDatumPlaneFeat$DatumPlaneFeat, and direct Java casts to WSession, WSolid, and WFeature fail with ClassCastException. This happens under both pfcSession.GetCurrentSessionWithCompatibility(C4Compatible) and pfcSession.GetCurrentSession(), and I reproduced it under both Amazon Corretto 21 and Oracle Java 21, so it does not appear to be a JVM vendor issue.

 

What makes this more confusing is that ordinary Java downcasting does work for PFC subtypes in the same environment: for example, Model -> Part and Feature -> DatumPlaneFeat succeed when the runtime type matches. Also, if I take the same returned PFC wrapper object, extract the CIP pointer, and construct the corresponding com.ptc.wfc.Implementation.wfc... wrapper reflectively, I can obtain usable WSession, WSolid, and WFeature objects and call at least some WFC methods successfully (for example WFeature.GetId()). So the issue seems very specifically to be the direct Java PFC-to-WFC cast boundary, not Java casting in general. Has anyone else seen this in Creo 12.x, and is there an officially supported Java mechanism for obtaining WSession / WSolid / WFeature from the returned PFC implementation objects when direct casts do not work?

1 reply

3-Newcomer
June 4, 2026

I have the sickening feeling that I have not been using startup otk_java in my .dat and instead i have been using startup java .  Investigating.