Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8199472

Fix non-PCH build after JDK-8199319

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: 11
    • Fix Version/s: 11
    • Component/s: hotspot
    • Subcomponent:
    • Resolved In Build:
      b07

      Description

      Change "8199319: Remove handles.inline.hpp include from reflectionUtils.hpp" breaks the non-PCH build (at least on Ubuntu 16.04 with gcc 5.4.0). If you configure with "--disable-precompiled-headers" you will get a whole lot of undefined reference for "Handle::Handle(Thread*, oopDesc*)" - see the end of this description.

      It seems that newer versions of GCC (and possibly other compilers as well) don't emit any code for inline functions if these functions can be inlined at all potential call sites.

      The problem in this special case is that "Handle::Handle(Thread*, oopDesc*)" is not declared "inline" in "handles.hpp", but its definition in "handles.inline.hpp" is declared "inline". This leads to a situation, where compilation units which only include "handles.hpp" will emit a call to "Handle::Handle(Thread*, oopDesc*)" while compilation units which include "handles.inline.hpp" will try to inline "Handle::Handle(Thread*, oopDesc*)". If all the inlining attempts are successful, no instance of "Handle::Handle(Thread*, oopDesc*)" will be generated in any of the object files. This will lead to the link errors listed below.

      The quick fix for this issue is to include "handles.inline.hpp" into all the compilation units with undefined references (listed below).

      The correct fix will be to declare "Handle::Handle(Thread*, oopDesc*)" inline in "handles.hpp". This will lead to warnings (which are treated as errors) if the inline definition is not available at a call site and will avoid linking error due to compiler optimizations. Unfortunately this requires a whole lot of follow-up changes, because "handles.hpp" defines some derived classes of "Handle" which all have implicitly inline constructors which all reference the base class "Handle::Handle(Thread*, oopDesc*)" constructor. So the constructors of the derived classes have to be explicitly declared inline in "handles.hpp" and their implementation has to be moved to "handles.inline.hpp". This change again triggers other changes for all files which relayed on the derived Handle classes having inline constructors...

      The following linker errors could be observed with gcc 5.4.0:

      hotspot/share/oops/arrayKlass.cpp:111: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/oops/arrayKlass.cpp:111: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/classfile/classListParser.cpp:347: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/classfile/classLoaderData.cpp:387: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/runtime/handles.hpp:121: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/runtime/jniHandles.cpp:532: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/runtime/jniHandles.cpp:532: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/runtime/jniHandles.cpp:532: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/runtime/jniHandles.cpp:532: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/oops/klass.cpp:523: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/oops/klass.cpp:537: more undefined references to `Handle::Handle(Thread*, oopDesc*)' follow
      hotspot/share/runtime/handles.hpp:121: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/runtime/handles.hpp:123: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/runtime/handles.hpp:124: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/classfile/stringTable.cpp:301: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/classfile/systemDictionaryShared.cpp:131: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/runtime/handles.hpp:121: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/runtime/handles.hpp:124: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/runtime/handles.hpp:121: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/classfile/systemDictionaryShared.cpp:152: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/classfile/systemDictionaryShared.cpp:202: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/runtime/handles.hpp:121: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/classfile/systemDictionaryShared.cpp:246: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/classfile/systemDictionaryShared.cpp:263: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/classfile/systemDictionaryShared.cpp:291: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/classfile/systemDictionaryShared.cpp:284: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/classfile/systemDictionaryShared.cpp:499: undefined reference to `Handle::Handle(Thread*, oopDesc*)'
      hotspot/share/classfile/verificationType.cpp:48: more undefined references to `Handle::Handle(Thread*, oopDesc*)' follow

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                simonis Volker Simonis
                Reporter:
                simonis Volker Simonis
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: