Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!rt.uk.eu.org!aioe.org!.POSTED!not-for-mail From: qwertmonkey@syberianoutpost.ru Newsgroups: comp.lang.java.programmer Subject: cannot find symbol? Date: Sat, 4 May 2013 04:01:44 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 110 Message-ID: NNTP-Posting-Host: jcJFTAhAdFLWfAXONlzC5w.user.speranza.aioe.org X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: NetComponents Xref: csiph.com comp.lang.java.programmer:23816 Basically I am passing a String array to a method (verify) defined in a generic way in an interface in order to create an object of a certain type I am checking that the object of the correct type is created but when I try to call a method java tells me "cannot find symbol" I squinted at it for a while, but can't see what is wrong with it What is wrong with this code? How do you fix that problem? Does it relate to the use of generic declarations and/or reflection? thanks, lbrtchx comp.lang.java.programmer: cannot find symbol? // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ import java.util.Date; import java.io.IOException; import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; // __ mock/test object class IADObj{ private int d; private String aS; private Date Dt; // __ IADObj(){} // __ public void setCtxt(int d, String aS, long lTm){ this.d = d; this.aS = aS; this.Dt = new Date(lTm); } // __ public String toString(){ return("// __ d: |" + d + "|, aS: |" + aS + "|, Dt: |" + Dt + "|"); } } // __ interface verifiableCLIContext06{ public boolean verifyCtxt(String[] aSArs, Class TpArgK); public T_Ctxt getCtxtDTO(); } // __ class DTO_T_Ctxt06 implements verifiableCLIContext06 { private T_Ctxt tCtxt; // operating context // __ DTO_T_Ctxt06(){ System.err.println("// __ object created: |" + getTimeStamp() + "|"); } // __ private String getTimeStamp(){ return((new Date()).toString()); } // __ public boolean verifyCtxt(String[] aSAr, Class TpArgK){ int iArSz= Integer.MIN_VALUE; boolean Is = ((aSAr != null) && ((iArSz = aSAr.length) > 0)); if(Is){ for(int i = 0; (i < iArSz); ++i){ System.err.println("// __ aSAr[" + i + "]: |" + aSAr[i] + "|"); } // __ try{ tCtxt = (T_Ctxt)TpArgK.newInstance(); System.err.println("// __ tCtxt.getClass(): |" + tCtxt.getClass() + "|"); /* tCtxt.setCtxt((new Integer(aSAr[0])).intValue(), aSAr[1], (new Long(aSAr[0])).longValue()); cannot find symbol symbol : method setCtxt(int,java.lang.String,long) location: class java.lang.Object tCtxt.setCtxt((new Integer(aSAr[0])).intValue(), aSAr[1], (new Long(aSAr[0])).longValue()); ^ */ }catch(InstantiationException InstX){ InstX.printStackTrace(System.err); } catch(IllegalAccessException IlglAxX){ IlglAxX.printStackTrace(); } }// (Is) // __ return(Is); } // __ public T_Ctxt getCtxtDTO(){ return(tCtxt); } } // __ public class DTO_T_Ctxt06Test{ public static void main(String[] args) { IADObj IAD = new IADObj(); String[] aSAr = new String[]{"37", "abc", (new Date()).toString()}; DTO_T_Ctxt06 DTO_T_Ctxt06 = new DTO_T_Ctxt06(); DTO_T_Ctxt06.verifyCtxt(aSAr, IAD.getClass()); } } // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~