List of usage examples for java.lang ReflectiveOperationException printStackTrace
public void printStackTrace()
From source file:pe.chalk.takoyaki.target.Target.java
public static Target<?> create(JSONObject properties) { final String type = properties.getString("type").toLowerCase(); if (!Takoyaki.getInstance().getTargetClasses().containsKey(type)) throw new IllegalArgumentException("Unknown type: " + type); try {/* w ww . j a va2s . c o m*/ return Takoyaki.getInstance().getTargetClasses().get(type).getConstructor(JSONObject.class) .newInstance(properties); } catch (ReflectiveOperationException e) { e.printStackTrace(); return null; } }
From source file:net.sourceforge.pmd.RuleSetFactory.java
/** * Parse a ruleset node to construct a RuleSet. * * @param ruleSetReferenceId/*from w ww .j ava2s .com*/ * The RuleSetReferenceId of the RuleSet being parsed. * @param withDeprecatedRuleReferences * whether rule references that are deprecated should be ignored * or not * @return The new RuleSet. */ private RuleSet parseRuleSetNode(RuleSetReferenceId ruleSetReferenceId, boolean withDeprecatedRuleReferences) throws RuleSetNotFoundException { try (CheckedInputStream inputStream = new CheckedInputStream( ruleSetReferenceId.getInputStream(resourceLoader), new Adler32());) { if (!ruleSetReferenceId.isExternal()) { throw new IllegalArgumentException( "Cannot parse a RuleSet from a non-external reference: <" + ruleSetReferenceId + ">."); } DocumentBuilder builder = createDocumentBuilder(); InputSource inputSource; if (compatibilityFilter != null) { inputSource = new InputSource(compatibilityFilter.filterRuleSetFile(inputStream)); } else { inputSource = new InputSource(inputStream); } Document document = builder.parse(inputSource); Element ruleSetElement = document.getDocumentElement(); RuleSetBuilder ruleSetBuilder = new RuleSetBuilder(inputStream.getChecksum().getValue()) .withFileName(ruleSetReferenceId.getRuleSetFileName()); if (ruleSetElement.hasAttribute("name")) { ruleSetBuilder.withName(ruleSetElement.getAttribute("name")); } else { LOG.warning("RuleSet name is missing. Future versions of PMD will require it."); ruleSetBuilder.withName("Missing RuleSet Name"); } NodeList nodeList = ruleSetElement.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { String nodeName = node.getNodeName(); if (DESCRIPTION.equals(nodeName)) { ruleSetBuilder.withDescription(parseTextNode(node)); } else if ("include-pattern".equals(nodeName)) { ruleSetBuilder.addIncludePattern(parseTextNode(node)); } else if ("exclude-pattern".equals(nodeName)) { ruleSetBuilder.addExcludePattern(parseTextNode(node)); } else if ("rule".equals(nodeName)) { parseRuleNode(ruleSetReferenceId, ruleSetBuilder, node, withDeprecatedRuleReferences); } else { throw new IllegalArgumentException(UNEXPECTED_ELEMENT + node.getNodeName() + "> encountered as child of <ruleset> element."); } } } if (!ruleSetBuilder.hasDescription()) { LOG.warning("RuleSet description is missing. Future versions of PMD will require it."); ruleSetBuilder.withDescription("Missing description"); } ruleSetBuilder.filterRulesByPriority(minimumPriority); return ruleSetBuilder.build(); } catch (ReflectiveOperationException ex) { ex.printStackTrace(); throw new RuntimeException("Couldn't find the class " + ex.getMessage(), ex); } catch (ParserConfigurationException | IOException | SAXException ex) { ex.printStackTrace(); throw new RuntimeException("Couldn't read the ruleset " + ruleSetReferenceId + ": " + ex.getMessage(), ex); } }