magento2 – Magento 2.3.5 Incompatible argument type errors during compilation

I am trying to compile after upgrading to Magento 2.3.5-p1
and I get this error:

public_html$ php bin/magento setup:di:compile
The directory "/public_html/generated/code/Magento" cannot be deleted Warning!rmdir(/public_html/generated/code/Magento): Directory not empty
public_html$ php bin/magento setup:di:compile
Compilation was started.
Interception cache generation... 6/8 (=========>---)  75% 1 min 399.0 MiBErrors during compilation:
        PlumrocketAmpBlockCatalogProductWidgetCategory
                Incompatible argument type: Required type: MagentoCatalogApiCategoryRepositoryInterface. Actual type: array; File:
/public_html/app/code/Plumrocket/Amp/Block/Catalog/Product/Widget/Category.php

        PlumrocketAmpControllerApiStoreSwitchAction
                Missed required argument storeSwitcher in parent::__construct call. File: /public_html/app/code/Plumrocket/Amp/Controller/Api/Store/SwitchAction.php
Total Errors Count: 2

Category.php file:

categoryRepository = $categoryRepository;
    }

    /**
     * Retrieve product collection
     *
     * @return MagentoCatalogModelResourceModelProductCollection|null
     */
    public function createCollection()
    {
        /** @var $collection MagentoCatalogModelResourceModelProductCollection */
        $collection = $this->productCollectionFactory->create();

        $collection = $this->_addProductAttributesAndPrices($collection)
            ->setVisibility($this->catalogProductVisibility->getVisibleInCatalogIds())
            ->addStoreFilter()
            ->setPageSize($this->getPageSize())
            ->setCurPage(1)
            ->setOrder($this->getSortBy(), $this->getSortOrder());

        $collection->addCategoryFilter($this->getCategory());

        return $collection;
    }

    /**
     * @return bool|null
     */
    private function canShow()
    {
        if (null === $this->canShow) {
            $this->canShow = null !== $this->getCategory();
        }

        return $this->canShow;
    }

    /**
     * Set default template for widget in cms page
     *
     * @return $this|MagentoCatalogWidgetBlockProductProductsList
     */
    protected function _beforeToHtml()
    {
        if (! $this->canShow()) {
            return $this;
        }

        if (! $this->getTemplate()) {
            $this->setTemplate('Plumrocket_Amp::catalog/product/widget/items.phtml');
        }

        return parent::_beforeToHtml();
    }

    /**
     * Disable render for invalid widgets
     *
     * @return string
     */
    protected function _toHtml()
    {
        if (! $this->canShow()) {
            return '';
        }

        return parent::_toHtml();
    }

    /**
     * Add cache key info
     *
     * @return array|int
     */
    public function getCacheKeyInfo()
    {
        $baseCacheKeyInfo = parent::getCacheKeyInfo();

        array_push($baseCacheKeyInfo, self::WIDGET_TYPE, $this->_getWidgetParams(true));

        return $baseCacheKeyInfo;
    }

    /**
     * @param bool $toString
     * @return array|string
     */
    protected function _getWidgetParams($toString = false)
    {
        $params = (
            $this->getCategoryId(),
            $this->getSortBy(),
            $this->getSortOrder(),
            $this->showAddToCart()
        );

        return $toString ? implode('|', $params) : $params;
    }

    /**
     * Get selected category
     *
     * @return null|MagentoCatalogApiDataCategoryInterface|MagentoCatalogModelCategory
     */
    public function getCategory()
    {
        try {
            return $this->categoryRepository->get($this->getCategoryId());
        } catch (MagentoFrameworkExceptionNoSuchEntityException $e) {
            return null;
        } catch (LocalizedException $e) {
            return null;
        }
    }

    /**
     * Retrieve count of products
     *
     * @return int
     */
    public function hasItems()
    {
        return $this->getProductCollection()->getSize();
    }

    /**
     * Retrieve number of products to display
     *
     * @return int
     */
    public function getPageSize()
    {
        if ((int)$this->getProductsCount()) {
            return (int)$this->getProductsCount();
        }

        return self::DEFAULT_PRODUCTS_COUNT;
    }

    /**
     * Retrieve category id
     *
     * @return int
     * @throws LocalizedException
     */
    public function getCategoryId()
    {
        $catId = $this->getData('category');
        if ($catId && strpos($catId, '/') !== false) {
            $result = explode('/', $catId);
            $catId = $result(1);
        }

        if (! (int)$catId || ! is_numeric($catId)) {
            throw new LocalizedException(__('Category id is not valid'));
        }

        return (int)$catId;
    }

    /**
     * Retrieve sort by: price, position and etc.
     *
     * @return mixed
     */
    public function getSortBy()
    {
        if (! $this->hasData('sort_by')) {
            $this->setData('sort_by', self::DEFAULT_COLLECTION_SORT_BY);
        }

        return $this->getData('sort_by');
    }

    /**
     * Retrieve sort order: asc/desc
     *
     * @return string
     */
    public function getSortOrder()
    {
        if (! $this->hasData('sort_order')) {
            $this->setData('sort_order', self::DEFAULT_COLLECTION_ORDER);
        }

        return $this->getData('sort_order');
    }

    /**
     * @return bool
     */
    public function showAddToCart()
    {
        if (! $this->hasData('show_add_to_cart')) {
            $this->setData('show_add_to_cart', self::DEFAULT_SHOW_ADD_TO_CART);
        }

        return (bool)$this->getData('show_add_to_cart');
    }
}

SwitchAction.php file:

ampResultFactory = $ampResultFactory;
    }

    /**
     * @return AmpJson
     */
    public function execute() : AmpJson
    {
        $ampJsonResult = $this->ampResultFactory->create();

        $currentActiveStore = $this->storeManager->getStore();

        $targetStoreCode = $this->_request->getParam(
            '___store',
            $this->storeCookieManager->getStoreCodeFromCookie()
        );
        $fromStoreCode = $this->_request->getParam('___from_store');

        $error = null;
        try {
            $fromStore = $this->storeRepository->get($fromStoreCode);
            $targetStore = $this->storeRepository->getActiveStoreByCode($targetStoreCode);
        } catch (StoreIsInactiveException $e) {
            $error = __('Requested store is inactive');
        } catch (NoSuchEntityException $e) {
            $error = __("The store that was requested wasn't found. Verify the store and try again.");
        }
        if ($error !== null) {
            $ampJsonResult->addErrorMessage($error);
        } else {
            $defaultStoreView = $this->storeManager->getDefaultStoreView();
            if ($defaultStoreView->getId() == $targetStore->getId()) {
                $this->storeCookieManager->deleteStoreCookie($targetStore);
            } else {
                $this->httpContext->setValue(Store::ENTITY, $targetStore->getCode(), $defaultStoreView->getCode());
                $this->storeCookieManager->setStoreCookie($targetStore);
            }
            if ($targetStore->isUseStoreInUrl()) {
                // Change store code in redirect url
                if (strpos($this->_redirect->getRedirectUrl(), $currentActiveStore->getBaseUrl()) !== false) {
                    $redirectUrl = str_replace(
                        $currentActiveStore->getBaseUrl(),
                        $targetStore->getBaseUrl(),
                        $this->_redirect->getRedirectUrl()
                    );
                } else {
                    $redirectUrl = $targetStore->getBaseUrl();
                }
            } else {
                $redirectUrl = $this->_redirect->getRedirectUrl();
            }

            $ampJsonResult->setFormRedirect($redirectUrl);
        }

        return $ampJsonResult;
    }
}

Any idea how to solve the problem?
Thanks a lot,
Kobi

Cross compilation for Windows cannot be carried out under Ubuntu 18.04

I've been around for ages and can't compile Bitcoin Core 0.19.1 on my Ubuntu 18.04 computer (no VM). I follow these instructions exactly:

sudo apt install build-essential libtool autotools-dev automake pkg-config bsdmainutils curl git g++-mingw-w64-x86-64
sudo update-alternatives --config x86_64-w64-mingw32-g++ #successfully changes to posix here
git clone https://github.com/bitcoin/bitcoin.git
cd bitcoin
cd depends
make HOST=x86_64-w64-mingw32
cd ..
./autogen.sh # not required when building from tarball
CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site ./configure --prefix=/
make 

everything goes well until autogenous Step. The configuration script runs normally, but I always get the same output no matter what I do …

Build Options:
  with endomorphism   = no
  with ecmult precomp = yes
  with jni            = no
  with benchmarks     = no
  with coverage       = no
  module ecdh         = no
  module recovery     = yes

  asm                 = x86_64
  bignum              = no
  field               = 64bit
  scalar              = 64bit

  CC                  = gcc
  CFLAGS              = -g -O2 -W -std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings -fvisibility=hidden -O3
  CPPFLAGS            = 
  LDFLAGS             = 

Fixing libtool for -rpath problems.

Options used to compile and link:
  with wallet   = yes
  with gui / qt = yes
    with bip70  = no
    with qr     = yes
  with zmq      = yes
  with test     = yes
    with prop   = no
    with fuzz   = no
  with bench    = yes
  with upnp     = yes
  use asm       = yes
  sanitizers    = 
  debug enabled = no
  gprof enabled = no
  werror        = no

  target os     = linux
  build os      = 

  CC            = /usr/bin/ccache gcc
  CFLAGS        = -g -O2
  CPPFLAGS      =   -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2  -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS
  CXX           = /usr/bin/ccache g++ -std=c++14
  CXXFLAGS      =   -fstack-reuse=none -Wstack-protector -fstack-protector-all  -Wall -Wextra -Wformat -Wvla -Wswitch -Wformat-security -Wredundant-decls  -Wno-unused-parameter -Wno-implicit-fallthrough   -g -O2
  LDFLAGS       = -pthread  -Wl,-z,relro -Wl,-z,now -pie  
  ARFLAGS       = cr

I tried to uninstall and install Ubuntu. There have also been several attempts to compile in a clean repository, but the output always shows that the target operating system is Linux. I run it do Order after that, but never get the exe. I'm stuck and I don't know what else to try. Any help would be appreciated.

Validation – Is it possible to check the parameter data type in the function without an error in the compilation time when calling this function in C #?

Is it possible to check the parameter data type in the function without an error in the compilation time when calling this function in C #?
I don't want to get a compile-time error while passing the wrong value to the function in C # like Javascript.

The following is my sample code:

class Program
{
    static int containsThatItem(char() arr1, char() arr2)
    {
        Dictionary map = new Dictionary();

        foreach (var e in arr1)
        {
            map.Add(e, true);
        }

        foreach (var e in arr2)
        {
            if (!map.ContainsKey(e))
            {
                continue;
            }

            if (map(e))
            {
                Console.WriteLine("Item Found!");
            }
        }

        return 0;
    }

    static void Main(string() args)
    {
        int() arr1 = { 0, 1, 2, 3 };
        char() arr2 = { 'a', 'b', 'c', 'd'};

        //Here I'm getting compile time error
        containsThatItem(arr1, arr2);   //All I want is to overcome this compile time error by adding validation of datatype inside the containsThatItem method.

        Console.ReadKey();
    }
}

Java – JSP compilation exception after Tomcat upgrade from 7.0.59 to 8.5.51

I updated the Tomcat version to 8.5.51 from 7.0.59. After this upgrade, when trying to access the index.jsp page, the following exception appears.

SEVERE: Servlet.service() for servlet (jsp) threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: (24) in the generated java file:
(/home/application_path/work/org/apache/jsp/index_005f_jsp.java)
The type index_005f_jsp must implement the inherited abstract method JspSourceImports.getPackageImports()

An error occurred at line: (24) in the generated java file:
(/home/application_path/work/org/apache/jsp/index_005f_jsp.java)
The type index_005f_jsp must implement the inherited abstract method JspSourceImports.getClassImports()

An error occurred at line: (38) in the generated java file:
(/home/application_path/work/org/apache/jsp/index_005f_jsp.java)
The type Set is not generic; it cannot be parameterized with arguments 

An error occurred at line: (40) in the generated java file:
(/home/application_path/work/org/apache/jsp/index_005f_jsp.java)
The type Set is not generic; it cannot be parameterized with arguments 

An error occurred at line: (43) in the generated java file:
(/home/application_path/work/org/apache/jsp/index_005f_jsp.java)
_jspx_imports_packages cannot be resolved to a variable

An error occurred at line: (44) in the generated java file:
(/home/application_path/work/org/apache/jsp/index_005f_jsp.java)
_jspx_imports_packages cannot be resolved

An error occurred at line: (64) in the generated java file:
(/home/application_path/work/org/apache/jsp/index_005f_jsp.java)
The type Set is not generic; it cannot be parameterized with arguments 

Stacktrace:
        at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
        at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:212)
        at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:552)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:381)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:351)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:335)
        at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:597)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:399)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:728)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:470)
        at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:395)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:316)
        at ActiveServerPkg.ActiveServer.doPost2(ActiveServer.java:1004)
        at ActiveServerPkg.ActiveServer.doPost(ActiveServer.java:253)
        at ActiveServerPkg.ActiveServer.doGet(ActiveServer.java:245)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:609)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:818)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1623)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:748)

Difference between generated servlet files

with Tomcat 7.0.59

public final class index_005f_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

with hangover 8.5.51

public final class index_005f_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent,
                 org.apache.jasper.runtime.JspSourceImports {

JspSourceImports Interface has been added to the device list

I thought it might be due to a change in code / syntax backward compatibility in the version, so I replaced my index.jsp content with simple Hello World Message but still facing the same problem.

Working directory also deleted, but no luck 🙁

Also tried solutions from the bottom left, but still not working.

Jasper exception when using Tomcat 9

JSP compilation fails with Tomcat 8.0.20. Works with 8.0.11

Performance optimization – efficiency of table vs. ConstantArray with compilation

I've been trying to tweak a bit of code in the past few days, but I think I may be misunderstanding how compiling certain objective functions works. As an example for most barebones, I've attached a screenshot below of the speeds for array creation with ConstantArray, Table, and the compiled versions of each version.

We see that ConstantArray is almost 10x faster than Table in this simplest case (perhaps not surprising given this simplicity). When we try to compile, ConstantArray cannot be compiled, and therefore the time required only increases due to the overhead, I assume. However, the compiled table call also increases over time. This is unexpected for me, so I think I have to do something wrong in this comparison. Any thoughts on how to speed up compiling tables if this is possible in such a situation? I should also note that using array is both categorically slower than both other options, both non-compiled and compiled.

Enter the image description here

c ++ – Various compilation options for compiler and linter in cmake

I have a small C ++ project trying to learn cmake. I am currently trying to include clang-tidy by checking if cmake finds an executable from clang-tidy and if so, the CMAKE_CXX_CLANG_TIDY Variable. As far as I know, after setting these variables, all compiled targets are created once with the compiler and once with Clang-Tidy.

Now I have the problem that I build with g ++ that knows more compiler flags than clang (e.g. -Wuseless-cast), so I get an error when fluffing with clang-tidy. I know I can do all of this with Clang, but to make my code robust I want to be able to do it with different compilers.

Is there a way to set different compilation options for the compiler and linter? I am currently checking which compiler I am using and would like to activate as many checks as possible. Is there a variable like CMAKE_CLANG_TIDY_COMPILE_OPTIONS or something like that to define multiple sets of compilation options?

Thank you in advance!
Regards, Sebastian

Compilation with a witness / certificate

Theoretically, what you are asking for has been investigated under the name "translation validation". See e.g. B. the following classic paper:

George C. Necula. "Translation validation for an optimizing compiler." PLDI 2000.

In practice, compiling is such a complicated and confusing process that I doubt that there is an easily verifiable certificate that proves that the whole compilation process was done correctly (including lexing, parsing, front-end, optimization, back- End, assembly, link, etc.). Academic work typically focuses on only one or two phases of the process (e.g. some of the stages of optimization).

Two separate points should be separated: Can the verifier be simpler than the compiler? Can the verifier be faster than the compiler?

Easier is interesting because it means that the verifier may be more trustworthy (e.g. less likely to have errors). The classic work on validating translations focuses on this case.

Another question is faster. Some optimizations are deterministic and will not benefit, but there are certainly many optimizations that involve a search over a certain range of possibilities. An extreme version of this is the concept of "super optimization", in which a short code sequence is optimized by searching through all possible optimized versions and finding the one that is fastest while semantically matching the original. See e.g. B. the following papers:

R. Sausnauskas, Y. Chen, P. Collingbourne, J. Ketema, G. Lup, J. Taneja, J. Regehr. "A synthesizing super optimizer."

Sorav Bansal, Alex Aiken. "Automatic generation of peephole super optimizers." ASPLOS 2006.

SQL Server – Slow query compilation, lots of reads during the compilation phase

I have a request for the following form

exec sp_executesql N' UPDATE table  SET column1 = 1, modify_date=N''2020-02-12 04:55:59.000'' WHERE (column5=@P1           AND column6=@P2           )',N'@P1 nvarchar(36),@P2 int',N'458986156148',87

I can't change anything about this query myself. It comes from an application.

Each time it runs, the update values ​​change so that a new query plan is generated and the previous plan is not reused.

Forced parameterization is enabled, but does not appear to have any effect on this query, probably due to the way it is executed.

When the query itself is executed, a total of 4 read processes for the update are displayed. In this case, the execution itself did not cause an update because no rows are returned for the where clause.

Enter the image description here

With the Profiler I see that the time between the receipt and the start of the query is almost the entire time of the query (1 second). The actual execution takes place almost immediately.

The profiler shows 455,000 readings !! that are not displayed in the query execution itself.

Enter the image description here

So now I'm wondering

  1. Can I force the query to use the same plan here? A plan guide only seems to be usable for the same query or for a query that is affected by a forced parameterization.
  2. Can we increase the compilation speed of this query? Where do the 455,000 readings come from? There are many statistics on this table (+ – 100), but 455,000 reads seem to be quite an exaggeration.

This is on SQL Server 2019, no cumulative updates yet. I've searched the CU change log for anything that might have to do with it.

RedHat Enterprise Linux – CentOS8 / RedHat8 – Disable AppStream modules during custom compilation?

This is a general question about AppStream modules in CentOS / RedHat 8. Should we disable the AppStream module for this app when custom compiling apps like Apache or PHP? I don't seem to find any direct reference in the documentation. Is there a benefit and / or need? Thanks a lot!