View | Details | Raw Unified | Return to bug 57367
Collapse All | Expand All

(-)/cygdrive/d/Local-Storage/Java-Packages/Apache/tomcat/apache-tomcat-7.0.57-src/java/org/apache/catalina/startup/ContextConfig.java (-13 / +30 lines)
Lines 1945-1951 Link Here
1945
                    try {
1945
                    try {
1946
                        is = jar.getEntryInputStream();
1946
                        is = jar.getEntryInputStream();
1947
                        processAnnotationsStream(
1947
                        processAnnotationsStream(
1948
                                is, fragment, handlesTypesOnly);
1948
                                is, fragment, handlesTypesOnly, url.toString());
1949
                    } catch (IOException e) {
1949
                    } catch (IOException e) {
1950
                        log.error(sm.getString("contextConfig.inputStreamJar",
1950
                        log.error(sm.getString("contextConfig.inputStreamJar",
1951
                                entryName, url),e);
1951
                                entryName, url),e);
Lines 2006-2012 Link Here
2006
                    try {
2006
                    try {
2007
                        is = dcUrlConn.getInputStream();
2007
                        is = dcUrlConn.getInputStream();
2008
                        processAnnotationsStream(
2008
                        processAnnotationsStream(
2009
                                is, fragment, handlesTypesOnly);
2009
                                is, fragment, handlesTypesOnly,url.getPath());
2010
                    } catch (IOException e) {
2010
                    } catch (IOException e) {
2011
                        log.error(sm.getString("contextConfig.inputStreamJndi",
2011
                        log.error(sm.getString("contextConfig.inputStreamJndi",
2012
                                url),e);
2012
                                url),e);
Lines 2043-2049 Link Here
2043
            FileInputStream fis = null;
2043
            FileInputStream fis = null;
2044
            try {
2044
            try {
2045
                fis = new FileInputStream(file);
2045
                fis = new FileInputStream(file);
2046
                processAnnotationsStream(fis, fragment, handlesTypesOnly);
2046
                processAnnotationsStream(fis, fragment, handlesTypesOnly, file.getAbsolutePath());
2047
            } catch (IOException e) {
2047
            } catch (IOException e) {
2048
                log.error(sm.getString("contextConfig.inputStreamFile",
2048
                log.error(sm.getString("contextConfig.inputStreamFile",
2049
                        file.getAbsolutePath()),e);
2049
                        file.getAbsolutePath()),e);
Lines 2064-2075 Link Here
2064
2064
2065
2065
2066
    protected void processAnnotationsStream(InputStream is, WebXml fragment,
2066
    protected void processAnnotationsStream(InputStream is, WebXml fragment,
2067
            boolean handlesTypesOnly)
2067
            boolean handlesTypesOnly, String url)
2068
            throws ClassFormatException, IOException {
2068
            throws ClassFormatException, IOException {
2069
2069
2070
        ClassParser parser = new ClassParser(is);
2070
        ClassParser parser = new ClassParser(is);
2071
        JavaClass clazz = parser.parse();
2071
        JavaClass clazz = parser.parse();
2072
        checkHandlesTypes(clazz);
2072
        checkHandlesTypes(clazz, url);
2073
2073
2074
        if (handlesTypesOnly) {
2074
        if (handlesTypesOnly) {
2075
            return;
2075
            return;
Lines 2100-2106 Link Here
2100
     * for an annotation that matches {@link HandlesTypes}.
2100
     * for an annotation that matches {@link HandlesTypes}.
2101
     * @param javaClass
2101
     * @param javaClass
2102
     */
2102
     */
2103
    protected void checkHandlesTypes(JavaClass javaClass) {
2103
    protected void checkHandlesTypes(JavaClass javaClass, String url) {
2104
2104
2105
        // Skip this if we can
2105
        // Skip this if we can
2106
        if (typeInitializerMap.size() == 0)
2106
        if (typeInitializerMap.size() == 0)
Lines 2117-2123 Link Here
2117
        Class<?> clazz = null;
2117
        Class<?> clazz = null;
2118
        if (handlesTypesNonAnnotations) {
2118
        if (handlesTypesNonAnnotations) {
2119
            // This *might* be match for a HandlesType.
2119
            // This *might* be match for a HandlesType.
2120
            populateJavaClassCache(className, javaClass);
2120
            populateJavaClassCache(className, javaClass, url);
2121
            JavaClassCacheEntry entry = javaClassCache.get(className);
2121
            JavaClassCacheEntry entry = javaClassCache.get(className);
2122
            if (entry.getSciSet() == null) {
2122
            if (entry.getSciSet() == null) {
2123
                try {
2123
                try {
Lines 2183-2189 Link Here
2183
            JavaClassCacheEntry entry) {
2183
            JavaClassCacheEntry entry) {
2184
        JavaClassCacheEntry start = entry;
2184
        JavaClassCacheEntry start = entry;
2185
        StringBuilder msg = new StringBuilder(className);
2185
        StringBuilder msg = new StringBuilder(className);
2186
        msg.append("->");
2186
        msg.append("(").append(entry.getUrl()).append(")->");
2187
2187
2188
        String parentName = entry.getSuperclassName();
2188
        String parentName = entry.getSuperclassName();
2189
        JavaClassCacheEntry parent = javaClassCache.get(parentName);
2189
        JavaClassCacheEntry parent = javaClassCache.get(parentName);
Lines 2191-2197 Link Here
2191
2191
2192
        while (count < 100 && parent != null && parent != start) {
2192
        while (count < 100 && parent != null && parent != start) {
2193
            msg.append(parentName);
2193
            msg.append(parentName);
2194
            msg.append("->");
2194
            msg.append("(").append(parent.getUrl()).append(")->");
2195
2195
2196
            count ++;
2196
            count ++;
2197
            parentName = parent.getSuperclassName();
2197
            parentName = parent.getSuperclassName();
Lines 2199-2215 Link Here
2199
        }
2199
        }
2200
2200
2201
        msg.append(parentName);
2201
        msg.append(parentName);
2202
        if (parent != null) {
2203
            if (parent == start) {
2204
                msg.append("(loop to first entry!)");
2205
            } else {
2206
                msg.append("(").append(parent.getUrl()).append(")");
2207
            }
2208
        }
2209
        if (count == 100 && parent != null && parent != start) {
2210
            msg.append("->...");
2211
        }
2202
2212
2203
        return msg.toString();
2213
        return msg.toString();
2204
    }
2214
    }
2205
2215
2206
    private void populateJavaClassCache(String className, JavaClass javaClass) {
2216
    private void populateJavaClassCache(String className, JavaClass javaClass, String url) {
2207
        if (javaClassCache.containsKey(className)) {
2217
        if (javaClassCache.containsKey(className)) {
2208
            return;
2218
            return;
2209
        }
2219
        }
2210
2220
2211
        // Add this class to the cache
2221
        // Add this class to the cache
2212
        javaClassCache.put(className, new JavaClassCacheEntry(javaClass));
2222
        javaClassCache.put(className, new JavaClassCacheEntry(javaClass, url));
2213
2223
2214
        populateJavaClassCache(javaClass.getSuperclassName());
2224
        populateJavaClassCache(javaClass.getSuperclassName());
2215
2225
Lines 2229-2235 Link Here
2229
            ClassParser parser = new ClassParser(is);
2239
            ClassParser parser = new ClassParser(is);
2230
            try {
2240
            try {
2231
                JavaClass clazz = parser.parse();
2241
                JavaClass clazz = parser.parse();
2232
                populateJavaClassCache(clazz.getClassName(), clazz);
2242
                String url = context.getLoader().getClassLoader().getResource(name).toString();
2243
                populateJavaClassCache(clazz.getClassName(), clazz, url);
2233
            } catch (ClassFormatException e) {
2244
            } catch (ClassFormatException e) {
2234
                log.debug(sm.getString("contextConfig.invalidSciHandlesTypes",
2245
                log.debug(sm.getString("contextConfig.invalidSciHandlesTypes",
2235
                        className), e);
2246
                        className), e);
Lines 2732-2748 Link Here
2732
    }
2743
    }
2733
2744
2734
    private static class JavaClassCacheEntry {
2745
    private static class JavaClassCacheEntry {
2746
        private final String url;
2735
        public final String superclassName;
2747
        public final String superclassName;
2736
2748
2737
        public final String[] interfaceNames;
2749
        public final String[] interfaceNames;
2738
2750
2739
        private Set<ServletContainerInitializer> sciSet = null;
2751
        private Set<ServletContainerInitializer> sciSet = null;
2740
2752
2741
        public JavaClassCacheEntry(JavaClass javaClass) {
2753
        public JavaClassCacheEntry(JavaClass javaClass, String url) {
2754
            this.url = url;
2742
            superclassName = javaClass.getSuperclassName();
2755
            superclassName = javaClass.getSuperclassName();
2743
            interfaceNames = javaClass.getInterfaceNames();
2756
            interfaceNames = javaClass.getInterfaceNames();
2744
        }
2757
        }
2745
2758
2759
        public String getUrl() {
2760
          return url;
2761
        }
2762
2746
        public String getSuperclassName() {
2763
        public String getSuperclassName() {
2747
            return superclassName;
2764
            return superclassName;
2748
        }
2765
        }

Return to bug 57367