Foros del Web » Programación para mayores de 30 ;) » Java »

Que hacer cuando aparece Recompile with -Xlint ?

Estas en el tema de Que hacer cuando aparece Recompile with -Xlint ? en el foro de Java en Foros del Web. Buenos dias al compilar mi programa java en netbeans, me sale el siguiente error: warning: [options] bootstrap class path not set in conjunction with -source ...
  #1 (permalink)  
Antiguo 14/05/2015, 07:16
 
Fecha de Ingreso: noviembre-2007
Mensajes: 17
Antigüedad: 16 años, 5 meses
Puntos: 0
Pregunta Que hacer cuando aparece Recompile with -Xlint ?

Buenos dias al compilar mi programa java en netbeans, me sale el siguiente error:

warning: [options] bootstrap class path not set in conjunction with -source 1.6
D:\Users\cherna08\CSOFIA\proyectos\MediacionXml_GG SN\src\mediacionxml_ggsn\LeerXML.java:94: warning: [unchecked] unchecked conversion
List<Element> campos_mi = campo.getChildren();
required: List<Element>
found: List

el codigo es el siguiente:

List campos_md = hijo.getChildren(); //ANTES
// List<Element> campos_md = new ArrayList<Element>();


String strArchivosCont = "";
//Se recorre la lista de campos de md
for (int j = 0; j < campos_md.size(); j++) {
//Se obtiene el elemento 'campo'
Element campo = (Element) campos_md.get(j);

//valida si el campo es mi
if (campo.getName().equals(objArchivoB.getStrMI())) {
List<Element> campos_mi = campo.getChildren(); ==AQUI INDICA EL ERROR

Lo que veo es que se requiere List<Element> y estoy enviando List ( a traves de campo.getChildren() ), como puedo transformarlo a List <Element>
Espero me puedan ayudar es urgente!!
  #2 (permalink)  
Antiguo 14/05/2015, 08:40
Avatar de Profesor_Falken  
Fecha de Ingreso: agosto-2014
Ubicación: Mountain View
Mensajes: 1.323
Antigüedad: 9 años, 8 meses
Puntos: 182
Respuesta: Que hacer cuando aparece Recompile with -Xlint ?

Buenas,

No es un error, sino un simple warning.

Se debe al uso de genericos. getChildren devuelve una lista no parametrizada y la intentas asignar a una lista de elementos Element.

De forma rápida y sin probar te propongo dos cosas:
-Simplemente suprimir el warning con la anotación @SuppressWarnings("unchecked")
-Parametrizar la lista haciendo List<Element> campos_mi = Collections.checkedList(campo.getChildren(), Element.class);

Un saludo
__________________
If to err is human, then programmers are the most human of us
  #3 (permalink)  
Antiguo 14/05/2015, 09:11
 
Fecha de Ingreso: noviembre-2007
Mensajes: 17
Antigüedad: 16 años, 5 meses
Puntos: 0
Respuesta: Que hacer cuando aparece Recompile with -Xlint ?

Hola Falken,

gracias por tu respuesta, me gustaria mucho saber como parametrizar la lista, no conozco mucho como manejar las colleciones

Intente lo que me sugieres y me sale esto

found: List
D:\Users\cherna08\CSOFIA\proyectos\MediacionXml_GG SN\src\mediacionxml_ggsn\LeerXML.java:84: warning: [unchecked] unchecked method invocation: method checkedList in class Collections is applied to given types
List<Element> campos_md = Collections.checkedList(hijo.getChildren(), Element.class);
required: List<E>,Class<E>
found: List,Class<Element>
where E is a type-variable:
E extends Object declared in method <E>checkedList(List<E>,Class<E>)

que puedo hacer?
  #4 (permalink)  
Antiguo 14/05/2015, 10:19
 
Fecha de Ingreso: noviembre-2007
Mensajes: 17
Antigüedad: 16 años, 5 meses
Puntos: 0
Respuesta: Que hacer cuando aparece Recompile with -Xlint ?

Buenas, influye el hecho que este usando
jdom-1.1.2.jar

entonces debo cambiarlo por otro jar que sea jdom2 para que permita que define java.util.List<Element> getChildren()).??
  #5 (permalink)  
Antiguo 14/05/2015, 14:51
 
Fecha de Ingreso: noviembre-2007
Mensajes: 17
Antigüedad: 16 años, 5 meses
Puntos: 0
Pregunta Respuesta: Que hacer cuando aparece Recompile with -Xlint ?

Hola Falken,

Ahora si me funciona la sugerencia que me diste pero tuve que bajar el otro jar
import org.jdom2.Element;

Quedó asi:
List<Element> campos_md = Collections.checkedList(hijo.getChildren(), Element.class) ;

---
Ahora me sale otro error:
warning: [options] bootstrap class path not set in conjunction with -source 1.6
D:\Users\cherna08\CSOFIA\proyectos\MediacionXml_GG SN\src\librerias\ReadFile.java:30: warning: [unchecked] unchecked call to add(E) as a member of the raw type ArrayList
buffer.add(line);
where E is a type-variable:
E extends Object declared in class ArrayList
-
tengo el siguiente codigo
private ArrayList buffer;
..
buffer = new ArrayList();
for(line = in.readLine(); line != null; line = in.readLine())
buffer.add(line);

no entiendo bien el error?? debo agregar a buffer un elemento tipo Element??
  #6 (permalink)  
Antiguo 15/05/2015, 00:46
Avatar de Profesor_Falken  
Fecha de Ingreso: agosto-2014
Ubicación: Mountain View
Mensajes: 1.323
Antigüedad: 9 años, 8 meses
Puntos: 182
Respuesta: Que hacer cuando aparece Recompile with -Xlint ?

Buenas,

Sigue sin ser un error. Es solo un warning.

En teoria bastaria con que utilices genericos para buffer.

Código Java:
Ver original
  1. private List<String> buffer;
  2. ....
  3. buffer = new ArrayList<String>();

P.D: intenta utilizar la opcion de Highlight la proxima vez para resaltar el codigo.

Un saludo
__________________
If to err is human, then programmers are the most human of us
  #7 (permalink)  
Antiguo 15/05/2015, 09:35
 
Fecha de Ingreso: noviembre-2007
Mensajes: 17
Antigüedad: 16 años, 5 meses
Puntos: 0
Pregunta Respuesta: Que hacer cuando aparece Recompile with -Xlint ?

Hola Falken, disculpa tanta molestia, me esta pasando que ahora el objeto Element no existe para la version jdom2. por lo que estoy cambiando el codigo para que reconozca esta version, pero tengo la duda de como ignorar el DTD con JDOM2??

Código:
En Jdom use esto y me funciono
// SAXBuilder builder = new SAXBuilder(false);
            //para no validar el archivo DTD que menciona dentro del xml
            builder.setValidation(false);
            builder.setFeature("http://xml.org/sax/features/validation", false);
            builder.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
            builder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
pero aqui nose como indicarselo en JDOM2, se puede??
  #8 (permalink)  
Antiguo 15/05/2015, 09:41
 
Fecha de Ingreso: noviembre-2007
Mensajes: 17
Antigüedad: 16 años, 5 meses
Puntos: 0
Respuesta: Que hacer cuando aparece Recompile with -Xlint ?

si quisiera suprimir warning como hago?? donde coloco
@SuppressWarnings("unchecked")
  #9 (permalink)  
Antiguo 15/05/2015, 09:46
Avatar de Profesor_Falken  
Fecha de Ingreso: agosto-2014
Ubicación: Mountain View
Mensajes: 1.323
Antigüedad: 9 años, 8 meses
Puntos: 182
Respuesta: Que hacer cuando aparece Recompile with -Xlint ?

Buenas,

Por lo que veo aqui:
http://www.jdom.org/docs/apidocs/org...uilder(boolean)

Cita:
@Deprecated
public SAXBuilder(boolean validate)
Deprecated. use SAXBuilder(XMLReaderJDOMFactory) with either XMLReaders.DTDVALIDATING or XMLReaders.NONVALIDATING
Creates a new JAXP-based SAXBuilder. The underlying parser will validate (using DTD) or not according to the given parameter. If you want Schema validation then use SAXBuilder(XMLReaders.XSDVALIDATOR)
Te bastaria con hacer:

Código Java:
Ver original
  1. SAXBuilder builder = new SAXBuilder(XMLReaders.NONVALIDATING);


Un saludo
__________________
If to err is human, then programmers are the most human of us
  #10 (permalink)  
Antiguo 15/05/2015, 10:04
 
Fecha de Ingreso: noviembre-2007
Mensajes: 17
Antigüedad: 16 años, 5 meses
Puntos: 0
Respuesta: Que hacer cuando aparece Recompile with -Xlint ?

listo!! ya vi que lo coloco arriba del metodo. Gracias y disculpen lo novata

Igual si hay forma de omitir el DTD en JDOM2 me interesa

Etiquetas: netbeans
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:47.